[Python-Dev] Recent changes to TextIOWrapper and its tests
"ja...py" at farowl.co.uk
Mon Mar 18 21:26:05 CET 2013
I'm pulling recent changes in the io module across to Jython. I am
looking for help understanding the changes in
That change set is about what should happen if the underlying buffer
does not return bytes when read, but instead, for example, unicode
characters. The test test_read_nonbytes() constructs a pathological text
stream reader t where the usual BytesIO or BufferedReader is replaced
with a StringIO. It then checks that r.read(1) and t.readlines() raise a
TypeError, that is, it tests that TextIOWrapper checks the type of what
it reads from the buffer.
The puzzle is that it requires t.read() to succeed.
When I insert a check for bytes type in all the places it seems
necessary in my code, I pass the first two conditions, but since
t.read() also raises TypeError, the overall test fails. Is reading the
stream with read() intended to succeed? Why is this desired?
More information about the Python-Dev