diff options
| author | Robert Collins <robertc@robertcollins.net> | 2011-04-25 12:52:29 +1200 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2011-04-25 12:52:29 +1200 |
| commit | 511dc0ea9c094c1891c5d220e9e069fd5cd85d29 (patch) | |
| tree | 92ea55ed96f5c8a52bd26be9216ac8986fd361e9 /python | |
| parent | da19b80b0744b61e92bf6a2f09dabdf40334d658 (diff) | |
| parent | fa32c611795141f3a01d5b993d7cd38ac3ecb9a5 (diff) | |
| download | subunit-511dc0ea9c094c1891c5d220e9e069fd5cd85d29.tar.gz | |
Merge Martin[gz]'s fix for make_stream_binary.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 14fb94d..c997296 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -1075,7 +1075,6 @@ class ProtocolTestCase(object): _make_stream_binary(stream) self._passthrough = passthrough self._forward = forward - _make_stream_binary(forward) def __call__(self, result=None): return self.run(result) @@ -1154,11 +1153,18 @@ def get_default_formatter(): return sys.stdout +if sys.version_info > (3, 0): + from io import UnsupportedOperation as _NoFilenoError +else: + _NoFilenoError = AttributeError + def _make_stream_binary(stream): """Ensure that a stream will be binary safe. See _make_binary_on_windows.""" - if getattr(stream, 'fileno', None) is not None: - print (stream, type(stream)) - _make_binary_on_windows(stream.fileno()) + try: + fileno = stream.fileno() + except _NoFilenoError: + return + _make_binary_on_windows(fileno) def _make_binary_on_windows(fileno): """Win32 mangles \r\n to \n and that breaks streams. See bug lp:505078.""" |
