Message214776
In Python 3.4, TextIOWrapper can not read from streams that return bytearrays or memoryviews:
from io import TextIOWrapper, BytesIO
class MyByteStream(BytesIO):
def read1(self, len_):
return memoryview(super().read(len_))
bs = MyByteStream(b'some data in ascii\n')
ss = TextIOWrapper(bs, encoding='ascii')
print(ss.read(200))
results in:
TypeError: underlying read1() should have returned a bytes object, not 'memoryview'
I don't think there's any good reason for TextIOWrapper not accepting any bytes-like object (especially now that b''.join finally accepts bytes-like objects as well). |
|
Date |
User |
Action |
Args |
2014-03-25 04:14:29 | nikratio | set | recipients:
+ nikratio |
2014-03-25 04:14:29 | nikratio | set | messageid: <1395720869.89.0.455515257207.issue21057@psf.upfronthosting.co.za> |
2014-03-25 04:14:29 | nikratio | link | issue21057 messages |
2014-03-25 04:14:29 | nikratio | create | |
|