From b5dbe188b005c8f1100ba9c6cb286612e01ee2cb Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 25 Apr 2011 00:37:52 +0100 Subject: Use try/except rather than getattr to test for fileno _make_stream_binary --- python/subunit/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'python') 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.""" -- cgit v1.2.1