New submission from Nikolaus Rath:
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).
----------
components: Library (Lib)
messages: 214776
nosy: nikratio
priority: normal
severity: normal
status: open
title: TextIOWrapper does not support reading bytearrays or memoryviews
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com