summaryrefslogtreecommitdiff
path: root/python/subunit/__init__.py
diff options
context:
space:
mode:
authorMartin <gzlist@googlemail.com>2011-04-25 00:37:52 +0100
committerMartin <gzlist@googlemail.com>2011-04-25 00:37:52 +0100
commit83ee9fc3528955994c55ba46c1784cbf6d3c3ae8 (patch)
tree4b990c0efa8eb2c51c7ffbf8a0abfe6be517b188 /python/subunit/__init__.py
parent970fe166268ac41a20aa6dc78e4c491ae5449173 (diff)
downloadsubunit-git-83ee9fc3528955994c55ba46c1784cbf6d3c3ae8.tar.gz
Use try/except rather than getattr to test for fileno _make_stream_binary
Diffstat (limited to 'python/subunit/__init__.py')
-rw-r--r--python/subunit/__init__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 5387cae..146d2c1 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -1139,9 +1139,11 @@ def get_default_formatter():
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 AttributeError:
+ 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."""