[docs] [issue21071] struct.Struct.format is bytes, but should be str

Serhiy Storchaka report at bugs.python.org
Thu Apr 27 03:05:22 EDT 2017


Serhiy Storchaka added the comment:

After changing the type of Struct.format to str we perhaps should deprecate accepting bytes as format. Currently this can lead to emitting a BytesWarning.

$ ./python -Wa -b
>>> import struct
>>> struct.pack('I', 12345)
b'90\x00\x00'
>>> struct.pack(b'I', 12345)
__main__:1: BytesWarning: Comparison between bytes and string
__main__:1: BytesWarning: Comparison between bytes and string
b'90\x00\x00'

----------

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


More information about the docs mailing list