diff options
Diffstat (limited to 'python/subunit/__init__.py')
| -rw-r--r-- | python/subunit/__init__.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 69acef5..dd3e951 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -1287,15 +1287,17 @@ def _make_binary_on_windows(fileno): def _unwrap_text(stream): """Unwrap stream if it is a text stream to get the original buffer.""" + exceptions = (_UnsupportedOperation, IOError) if sys.version_info > (3, 0): unicode_type = str else: unicode_type = unicode + exceptions += (ValueError,) try: # Read streams if type(stream.read(0)) is unicode_type: return stream.buffer - except (_UnsupportedOperation, IOError): + except exceptions: # Cannot read from the stream: try via writes try: stream.write(_b('')) |
