Always print using utf-8. Fixes #362

This commit is contained in:
Matt Martz 2017-03-17 16:21:01 -05:00
parent 55b3cf14a3
commit d712f947d9
1 changed files with 2 additions and 3 deletions

View File

@ -148,8 +148,7 @@ except ImportError:
Taken from https://pypi.python.org/pypi/six/ Taken from https://pypi.python.org/pypi/six/
Modified to set encoding to UTF-8 if not set when stdout may not be Modified to set encoding to UTF-8 always
a tty such as when piping to head
""" """
fp = kwargs.pop("file", sys.stdout) fp = kwargs.pop("file", sys.stdout)
if fp is None: if fp is None:
@ -159,7 +158,7 @@ except ImportError:
if not isinstance(data, basestring): if not isinstance(data, basestring):
data = str(data) data = str(data)
# If the file has an encoding, encode unicode with it. # If the file has an encoding, encode unicode with it.
encoding = fp.encoding or 'UTF-8' # Diverges for notty encoding = 'UTF-8' # Always trust UTF-8 for output
if (isinstance(fp, file) and if (isinstance(fp, file) and
isinstance(data, unicode) and isinstance(data, unicode) and
encoding is not None): encoding is not None):