[Python-Dev] Recent changes to TextIOWrapper and its tests

Serhiy Storchaka storchaka at gmail.com
Tue Mar 19 00:56:51 CET 2013


On 18.03.13 22:26, Jeff Allen wrote:
> 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?

This is not desired. I just registered the current behavior. Python 3 is 
more strict and always raises an exception.

Perhaps this test should be relaxed. I.e. use

     with self.maybeRaises(TypeError):
         t.read()

and define maybeRaises() as:

     @contextlib.contextmanager
     def maybeRaises(self, *args, **kwds):
         try:
             yield
         except args:
             pass




More information about the Python-Dev mailing list