Message331678
I agree, that it would be right to accept only binary strings when write to binary stream. But I afraid that it is too late to change this in the 16th bugfix of 2.7. This can break existing code or tests.
I suggest to change the behavior only in the Py3k compatibility mode. PR 11127 is based on issue_8765.diff, but emits a warning when run Python with the -3 option.
$ ./python -3 -c "import io; io.FileIO('/dev/null', 'w').write(u'')"
-c:1: DeprecationWarning: write() argument must be string or buffer, not 'unicode'
$ ./python -3 -We -c "import io; io.FileIO('/dev/null', 'w').write(u'')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
DeprecationWarning: write() argument must be string or buffer, not 'unicode'
This will help to migrate to Python 3, but keeps the behavior unchanged in normal run. |
|
Date |
User |
Action |
Args |
2018-12-12 08:11:50 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, amaury.forgeotdarc, pitrou, pakal, ysj.ray |
2018-12-12 08:11:49 | serhiy.storchaka | set | messageid: <1544602309.93.0.788709270274.issue8765@psf.upfronthosting.co.za> |
2018-12-12 08:11:49 | serhiy.storchaka | link | issue8765 messages |
2018-12-12 08:11:49 | serhiy.storchaka | create | |
|