Plugins/CheckerPlugins/Pep8/pep8.py

branch
Py2 comp.
changeset 2607
e5115553185a
parent 2302
f29e9405c851
child 2847
1843ef6e2656
diff -r affc66a603c7 -r e5115553185a Plugins/CheckerPlugins/Pep8/pep8.py
--- a/Plugins/CheckerPlugins/Pep8/pep8.py	Sat Apr 20 20:29:37 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/pep8.py	Sun Apr 21 20:30:56 2013 +0200
@@ -364,13 +364,12 @@
     """
     line = physical_line.rstrip()
     length = len(line)
-    if length > MAX_LINE_LENGTH:
-        try:
-            # The line could contain multi-byte characters
-            if hasattr(line, 'decode'):   # Python 2 only
-                length = len(line.decode('utf-8'))
-        except UnicodeDecodeError:
-            pass
+    try:
+        # The line could contain multi-byte characters
+        if hasattr(line, 'decode'):   # Python 2 only
+            length = len(line.decode('utf-8'))
+    except (UnicodeDecodeError, UnicodeEncodeError):
+        pass    
     if length > MAX_LINE_LENGTH:
         return MAX_LINE_LENGTH, "E501", length
 
@@ -985,7 +984,8 @@
         for name, check, argument_names in options.physical_checks:
             result = self.run_check(check, argument_names)
             if result is not None:
-                offset, code, *args = result
+                offset, code = result[:2]
+                args = result[2:]
                 self.report_error_args(self.line_number, offset, code, check,
                     *args)
 
@@ -1041,7 +1041,8 @@
                 print('   ' + name)
             result = self.run_check(check, argument_names)
             if result is not None:
-                offset, code, *args = result
+                offset, code = result[:2]
+                args = result[2:]
                 if isinstance(offset, tuple):
                     original_number, original_offset = offset
                 else:

eric ide

mercurial