Martin Panter added the comment:
Okay, I was trying to confirm your proposal in Python 3 terms, because in
Python 2, str has a different meaning and I was confused.
I agree that the existence of the decoding mode is a design bug, so how would
you feel about deprecating it, at least in the documentation? I.e. in Python 3,
deprecate usage like str(buffer, "utf-8") in favour of buffer.decode("utf-8")
or using the codecs module directly. If this was done, it would clearly remove
the need for an encoding parameter to str() in all cases. I would be in favour
of deprecating the complementary bytes() and bytearray() encoding modes as well.
Do you have an example use case in Python 3 that would benefit from always
allowing an encoding parameter? I can understand that your to_unicode()
function could be useful in Python 2. But in Python 3, byte strings tend to
hold raw data that is not necessarily textual at all. There are some places
(warts in my opinion) such as the binascii module where ASCII-encoded byte
strings are common, but I still don’t think this proposal would be very helpful
with that.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24019>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com