I'm pulling recent changes in the io module across to Jython. I am looking for help understanding the changes in
http://hg.python.org/cpython/rev/19a33ef3821d

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?

Jeff Allen



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to