[issue32078] string result of str(bytes()) in Python3

STINNER Victor report at bugs.python.org
Mon Nov 20 12:09:57 EST 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

Calling str(bytes) is wrong in Python 3:

$ python3 -bb
Python 3.6.2 (default, Oct  2 2017, 16:51:32) 
>>> str(b'abc')
BytesWarning: str() on a bytes instance

Just don't do that :-)

Use repr(bytes) if you want the b'...' format:

>>> repr(b'abc')
"b'abc'"

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32078>
_______________________________________


More information about the Python-bugs-list mailing list