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 | e9548695dc187a9f7e9f0494408b6d07ede547f2 (patch) | |
| tree | 92ea55ed96f5c8a52bd26be9216ac8986fd361e9 /python | |
| parent | d8df52062fbcee4da77b6e1cdb701defa2e8a2da (diff) | |
| parent | 264161d485bfb5e2e952b329eb53d0a60555bced (diff) | |
| download | subunit-git-e9548695dc187a9f7e9f0494408b6d07ede547f2.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.""" |
