Fix for the PEP-8 checker to handle unicode better. 5_1_x

Wed, 29 Jun 2011 13:51:58 +0200

author
detlev@die-offenbachs.de
date
Wed, 29 Jun 2011 13:51:58 +0200
branch
5_1_x
changeset 1146
8ddb232355b9
parent 1141
3017c0a73c73
child 1151
b64cf188c5d7

Fix for the PEP-8 checker to handle unicode better.
(transplanted from 2a16484e65c260b2610034f0021be78e8cd124d5)

Plugins/CheckerPlugins/Pep8/pep8.py file | annotate | diff | comparison | revisions
UtilitiesPython2/pep8.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/Pep8/pep8.py	Tue Jun 28 19:23:57 2011 +0200
+++ b/Plugins/CheckerPlugins/Pep8/pep8.py	Wed Jun 29 13:51:58 2011 +0200
@@ -367,9 +367,8 @@
     if length > MAX_LINE_LENGTH:
         try:
             # The line could contain multi-byte characters
-            if not hasattr(line, 'decode'):   # Python 3
-                line = line.encode('latin-1')
-            length = len(line.decode('utf-8'))
+            if hasattr(line, 'decode'):   # Python 2 only
+                length = len(line.decode('utf-8'))
         except UnicodeDecodeError:
             pass
     if length > MAX_LINE_LENGTH:
--- a/UtilitiesPython2/pep8.py	Tue Jun 28 19:23:57 2011 +0200
+++ b/UtilitiesPython2/pep8.py	Wed Jun 29 13:51:58 2011 +0200
@@ -256,9 +256,8 @@
     if length > MAX_LINE_LENGTH:
         try:
             # The line could contain multi-byte characters
-            if not hasattr(line, 'decode'):   # Python 3
-                line = line.encode('latin-1')
-            length = len(line.decode('utf-8'))
+            if hasattr(line, 'decode'):   # Python 2 only
+                length = len(line.decode('utf-8'))
         except UnicodeDecodeError:
             pass
     if length > MAX_LINE_LENGTH:

eric ide

mercurial