From ea5c7b8a4200a6d32cb9d868e19285df05515624 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 27 Jan 2013 13:55:33 +1300 Subject: [PATCH 1/1] Tweak Python3 support to help testrepository get 3-ready. --- NEWS | 10 ++++++++++ python/subunit/__init__.py | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 081dc5d..93c87cc 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,16 @@ subunit release notes NEXT (In development) --------------------- +BUG FIXES +~~~~~~~~~ + +* UnsupportedOperation is available in the Python2.6 io library, so ask + forgiveness rather than permission for obtaining it. (Robert Collins) + +* Streams with no fileno() attribute are now supported, but they are not + checked for being in binary mode: be sure to take care of that if using + the library yourself. (Robert Collins) + 0.0.9 ----- diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 42dcf29..dfc5e94 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -121,9 +121,9 @@ import re import subprocess import sys import unittest -if sys.version_info > (3, 0): +try: from io import UnsupportedOperation as _UnsupportedOperation -else: +except ImportError: _UnsupportedOperation = AttributeError @@ -1285,7 +1285,7 @@ def _make_stream_binary(stream): """ try: fileno = stream.fileno() - except _UnsupportedOperation: + except (_UnsupportedOperation, AttributeError): pass else: _make_binary_on_windows(fileno) -- 2.34.1