Fix test_console.py on Python 3

This is a alternative fix I suggested in the comments on PR #273.
This commit is contained in:
Marius Gedminas 2019-09-09 18:52:29 +03:00
parent 4e6c806bff
commit 60f9f80b9f

View file

@ -202,4 +202,6 @@ def get_encoded_writer (out=sys.stdout, encoding=None, errors='replace'):
if encoding is None:
encoding = default_encoding
Writer = codecs.getwriter(encoding)
return Writer(out, errors)
# Use sys.stdout.buffer on Python 3, but sys.stdout itself on Python 2
buffer = getattr(out, 'buffer', out)
return Writer(buffer, errors)