Serhiy Storchaka <[email protected]> added the comment:
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.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue8765>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com