summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-16 18:59:31 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-16 18:59:31 +0300
commita64572f713217ec4733c99409e175a9f2d31cb68 (patch)
tree561ede60cd00ee085c1dda43eb12d002b54d6095
parentb90d1a88f2e6d45abbd7a0fed48dfb21d92cb8fc (diff)
downloadpylint-a64572f713217ec4733c99409e175a9f2d31cb68.tar.gz
Make encode a proper method of the BaseReporter, which removes the need of patching it all the time.
-rw-r--r--pylint/reporters/__init__.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py
index 5c4437a..7eabacf 100644
--- a/pylint/reporters/__init__.py
+++ b/pylint/reporters/__init__.py
@@ -52,7 +52,6 @@ class BaseReporter(object):
self.section = 0
self.out = None
self.out_encoding = None
- self.encode = None
self.set_output(output)
# Build the path prefix to strip to get relative paths
self.path_strip_prefix = os.getcwd() + os.sep
@@ -75,12 +74,11 @@ class BaseReporter(object):
def set_output(self, output=None):
"""set output stream"""
self.out = output or sys.stdout
- # py3k streams handle their encoding :
- if sys.version_info >= (3, 0):
- self.encode = lambda x: x
- return
- def encode(string):
+ if six.PY3:
+ encode = lambda self, string: string
+ else:
+ def encode(self, string):
if not isinstance(string, six.text_type):
return string
encoding = (getattr(self.out, 'encoding', None) or
@@ -90,7 +88,6 @@ class BaseReporter(object):
# source code line that can't be encoded with the current locale
# settings
return string.encode(encoding, 'replace')
- self.encode = encode
def writeln(self, string=''):
"""write a line in the output buffer"""