[issue26555] string.format(bytes) raise warning

STINNER Victor report at bugs.python.org
Mon Mar 14 10:33:28 EDT 2016


STINNER Victor added the comment:

> Well, it's not what format() is doing now, using str()? :)

Hum, are you sure that you tried Python 3, and not Python 2?

str(bytes) on Python 3 is well defined:

>>> print(str(b'hello'))
b'hello'
>>> print(str('h\xe9llo'.encode('utf8')))
b'h\xc3\xa9llo'

I'm not sure that you expect the b'...' format. Non-ASCII characters are escaped as \xHH format.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26555>
_______________________________________


More information about the Python-bugs-list mailing list