Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2017-11-22.07:40:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511336416.94.0.213398074469.issue32110@psf.upfronthosting.co.za>
In-reply-to
Content
Usually the read() method of a file-like object takes one optional argument which limits the amount of data (the number of bytes or characters) returned if specified.

codecs.StreamReader.read() also has such parameter. But this is the second parameter. The first parameter limits the number of bytes read for decoding. read(1) can return 70 characters, that will confuse most callers which expect either a single character or an empty string (at the end of stream).

Some times ago codecs.open() was recommended as a replacement for the builtin open() in programs that should work in 2.x and 3.x (this was before adding io.open()), and it is still used in many programs. But this peculiarity makes it bad replacement of builtin open().

I wanted to fix this issue long time ago, but forgot, and the question on Stack Overflow has reminded me about this. https://stackoverflow.com/questions/46437761/codecs-openutf-8-fails-to-read-plain-ascii-file
History
Date User Action Args
2017-11-22 07:40:16serhiy.storchakasetrecipients: + serhiy.storchaka
2017-11-22 07:40:16serhiy.storchakasetmessageid: <1511336416.94.0.213398074469.issue32110@psf.upfronthosting.co.za>
2017-11-22 07:40:16serhiy.storchakalinkissue32110 messages
2017-11-22 07:40:16serhiy.storchakacreate