Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

branch
5_5_x
changeset 3742
ea909da895ab
parent 3616
081b69e00f3e
child 3820
c00bdab507ef
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Thu Jul 31 16:37:52 2014 +0200
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Thu Jul 31 16:53:43 2014 +0200
@@ -104,14 +104,6 @@
         hangClosing, docType, errors, eol, encoding, backup = args
     
     stats = {}
-    # avoid 'Encoding declaration in unicode string' exception on Python2
-    if sys.version_info[0] == 2:
-        if encoding == 'utf-8-bom':
-            enc = 'utf-8'
-        else:
-            enc = encoding
-        source = [line.encode(enc) for line in source]
-    
     # Don't check an empty file
     if source == []:
         return stats, []
@@ -125,6 +117,14 @@
         fixer = None
     
     if not errors:
+        # avoid 'Encoding declaration in unicode string' exception on Python2
+        if sys.version_info[0] == 2:
+            if encoding == 'utf-8-bom':
+                enc = 'utf-8'
+            else:
+                enc = encoding
+            source = [line.encode(enc) for line in source]
+        
         if includeMessages:
             select = [s.strip() for s in
                       includeMessages.split(',') if s.strip()]

eric ide

mercurial