Merge pull request #277 from linkchecker/python3_23_alt

Fix test_console.py on Python 3
This commit is contained in:
anarcat 2019-09-09 14:13:45 -04:00 committed by GitHub
commit 5179e47c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)