[issue21057] TextIOWrapper does not support reading bytearrays or memoryviews

Nikolaus Rath report at bugs.python.org
Tue Mar 25 22:00:17 CET 2014


Nikolaus Rath added the comment:

On 03/25/2014 01:39 PM, Serhiy Storchaka wrote:
> read1() should return bytes. MyByteStream doesn't implement the io.BufferedIOBase interface.

Indeed, this is what this issue is about :-).

The question is: is there a good reason to require io.BufferedIOBase
implementors to return bytes rather than any bytes-like object from read1?

I'd also argue that the current documentation of io.BufferedIOBase
actually does not clearly require read1 to return bytes. The exact
formulation is "Read and return up to *size* bytes" (note that "bytes"
is not interpreted text). This can just as easily read as "return binary
data of up to *size* bytes using one of the customary Python types".

So if it turns out that there is a good reason for this requirement, the
documentation should at least make this requirement more explicit.

Best,
-Nikolaus

-- 
Encrypted emails preferred.
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

             »Time flies like an arrow, fruit flies like a Banana.«

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21057>
_______________________________________


More information about the Python-bugs-list mailing list