Comment 6 for bug 987514

Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :

The exceptions are different:

$ python3.1 -c 'open("/dev/null", "w").read()'
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 IOError: not readable
 $ python3.2 -c 'open("/dev/null", "w").read()'
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 io.UnsupportedOperation: not readable

The following fix works, but maybe _UnsupportedOperation should be changed.

--- python/subunit/__init__.py
 +++ python/subunit/__init__.py
 @@ -1280,7 +1280,7 @@
              # Read streams
              if type(stream.read(0)) is str:
                  return stream.buffer
 - except _UnsupportedOperation:
 + except (_UnsupportedOperation, IOError):
              # Cannot read from the stream: try via writes
              try:
                  stream.write(_b(''))