[issue34437] print statement using \x results in improper and extra bytes
Steven D'Aprano
report at bugs.python.org
Sun Aug 19 20:20:07 EDT 2018
Steven D'Aprano <steve+python at pearwood.info> added the comment:
You wrote:
> There are 6 bytes not 4 and where did the c3, bd, and c2 come from?
In Python 2, strings are byte strings, in Python 3, strings by default are Unicode text strings. You are seeing the UTF-8 representation of the text string.
py> "\xfd\x84\x04\x08".encode('utf-8')
b'\xc3\xbd\xc2\x84\x04\x08'
So the behaviour in Python 3 is correct and not a bug, it has just changed (intentionally) from Python 2.
Googling may help you find more about this:
https://duckduckgo.com/?q=python3+write+bytes+to+stdout
----------
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34437>
_______________________________________
More information about the Python-bugs-list
mailing list