This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients amaury.forgeotdarc, pakal, pitrou, serhiy.storchaka, ysj.ray
Date 2018-12-12.08:11:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544602309.93.0.788709270274.issue8765@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-12 08:11:50serhiy.storchakasetrecipients: + serhiy.storchaka, amaury.forgeotdarc, pitrou, pakal, ysj.ray
2018-12-12 08:11:49serhiy.storchakasetmessageid: <1544602309.93.0.788709270274.issue8765@psf.upfronthosting.co.za>
2018-12-12 08:11:49serhiy.storchakalinkissue8765 messages
2018-12-12 08:11:49serhiy.storchakacreate