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

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

author
detlev@die-offenbachs.de
date
Wed, 29 Jun 2011 13:51:58 +0200
changeset 1145
2a16484e65c2
parent 1144
6185688709ff
child 1147
5dc04e6593d7

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

Plugins/CheckerPlugins/Pep8/pep8.py file | annotate | diff | comparison | revisions
UtilitiesPython2/pep8.py file | annotate | diff | comparison | revisions
diff -r 6185688709ff -r 2a16484e65c2 Plugins/CheckerPlugins/Pep8/pep8.py
--- a/Plugins/CheckerPlugins/Pep8/pep8.py	Wed Jun 29 08:01:51 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:
diff -r 6185688709ff -r 2a16484e65c2 UtilitiesPython2/pep8.py
--- a/UtilitiesPython2/pep8.py	Wed Jun 29 08:01:51 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