diff options
| author | Martin <gzlist@googlemail.com> | 2011-07-01 16:55:32 +0100 |
|---|---|---|
| committer | Martin <gzlist@googlemail.com> | 2011-07-01 16:55:32 +0100 |
| commit | 7d6fa09296e59fe12a568658e644c3ba1a9cc7e2 (patch) | |
| tree | c404011ea6ac1fae80a95834082f1b128b94100c /testtools/compat.py | |
| parent | d3d5b3a16e8baf742ec64f7d8a04e9143fc2f798 (diff) | |
| download | testtools-7d6fa09296e59fe12a568658e644c3ba1a9cc7e2.tar.gz | |
Wrap unicode streams on Python 2 so writing as well as printing unicode to them works
Diffstat (limited to 'testtools/compat.py')
| -rw-r--r-- | testtools/compat.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/testtools/compat.py b/testtools/compat.py index 61d6e60..f2bc54b 100644 --- a/testtools/compat.py +++ b/testtools/compat.py @@ -119,7 +119,9 @@ def unicode_output_stream(stream): return codecs.getwriter("ascii")(stream, "replace") if writer.__module__.rsplit(".", 1)[1].startswith("utf"): # The current stream has a unicode encoding so no error handler is needed - return stream + if sys.version_info > (3, 0): + return stream + return writer(stream) if sys.version_info > (3, 0): # Python 3 doesn't seem to make this easy, handle a common case try: |
