Checking output line and encoding it if it is Unicode

This commit is contained in:
Aleskarova, Dinara 2017-04-20 09:58:25 +04:00
parent 733a4f053b
commit 1ae5e0afe6

View file

@ -166,6 +166,8 @@ class BaseFormatter(object):
def _write(self, output):
"""Handle logic of whether to use an output file or print()."""
if not isinstance(output, str):
output = output.encode('UTF-8')
if self.output_fd is not None:
self.output_fd.write(output + self.newline)
if self.output_fd is None or self.options.tee: