From 394f21a1f0832d0e4dda8e68d654d52ed6ad5be8 Mon Sep 17 00:00:00 2001 From: "Aleskarova, Dinara" Date: Mon, 24 Apr 2017 11:58:11 +0400 Subject: [PATCH] Encoding output if it's Unicode only for python2 --- src/flake8/formatting/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flake8/formatting/base.py b/src/flake8/formatting/base.py index 180380a..2a85f09 100644 --- a/src/flake8/formatting/base.py +++ b/src/flake8/formatting/base.py @@ -1,6 +1,7 @@ """The base class and interface for all formatting plugins.""" from __future__ import print_function +import sys class BaseFormatter(object): """Class defining the formatter interface. @@ -166,7 +167,7 @@ class BaseFormatter(object): def _write(self, output): """Handle logic of whether to use an output file or print().""" - if not isinstance(output, str): + if sys.version_info < (3, 0) and isinstance(output, unicode): output = output.encode('UTF-8') if self.output_fd is not None: self.output_fd.write(output + self.newline)