[issue21071] struct.Struct.format is bytes, but should be str
STINNER Victor
report at bugs.python.org
Mon Mar 27 07:14:00 EDT 2017
STINNER Victor added the comment:
I created https://github.com/python/cpython/pull/845 to change struct.Struct.format type to str (Unicode).
struct.Struct() accepts bytes and str format strings, so it's not really a backward incompatible change.
It's just a minor enhancement to help development:
$ ./python
Python 3.7.0a0 (heads/master-dirty:b8a7daf, Mar 27 2017, 13:02:20)
>>> print(struct.Struct('hi').format)
hi
Without the patch:
haypo at selma$ python3
Python 3.5.2 (default, Sep 14 2016, 11:28:32)
[GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> print(struct.Struct('hi').format)
b'hi'
haypo at selma$ python3 -bb
Python 3.5.2 (default, Sep 14 2016, 11:28:32)
>>> import struct
>>> print(struct.Struct('hi').format)
Traceback (most recent call last):
...
BytesWarning: str() on a bytes instance
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21071>
_______________________________________
More information about the Python-bugs-list
mailing list