Message290584
| Author |
vstinner |
| Recipients |
Arfrever, benjamin.peterson, docs@python, martin.panter, r.david.murray, rhettinger, serhiy.storchaka, vstinner, zbysz |
| Date |
2017年03月27日.11:14:00 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1490613240.64.0.0175429067557.issue21071@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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@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@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 |
|