mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 13:36:54 +00:00
Encoding output if it's Unicode only for python2
This commit is contained in:
parent
1ae5e0afe6
commit
394f21a1f0
1 changed files with 2 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue