[issue16349] Document whether it's safe to use bytes for struct format string
Terry J. Reedy
report at bugs.python.org
Fri Nov 2 22:28:35 CET 2012
Terry J. Reedy added the comment:
For 3.3, I verified that adding b prefix to first three doc examples gives same output as without, but also discovered that example outputs are wrong, at least on windows, because of byte ordering issues.
>>> pack('hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack(b'hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack(b'hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)
----------
nosy: +mark.dickinson, meador.inge, terry.reedy
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16349>
_______________________________________
More information about the Python-bugs-list
mailing list