eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py

changeset 7637
c878e8255972
parent 7635
0cdead130a81
child 7639
422fd05e9c91
--- a/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Mon Jun 22 17:55:06 2020 +0200
+++ b/eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Tue Jun 23 17:24:18 2020 +0200
@@ -7,14 +7,9 @@
 Module implementing the syntax check for Python 2/3.
 """
 
-try:  # Only for Py2
-    import Queue as queue
-except ImportError:
-    import queue
-
+import queue
 import ast
 import re
-import sys
 import traceback
 import multiprocessing
 
@@ -66,13 +61,6 @@
 
     if codestring and codestring[-1] != '\n':
         codestring = codestring + '\n'
-
-    # Check type for py2: if not str it's unicode
-    if sys.version_info[0] == 2:
-        try:
-            codestring = codestring.encode('utf-8')
-        except UnicodeError:
-            pass
     
     return codestring
 
@@ -235,11 +223,6 @@
         import __builtin__ as builtins        # __IGNORE_WARNING__
     
     try:
-        if sys.version_info[0] == 2:
-            file_enc = filename.encode(sys.getfilesystemencoding())
-        else:
-            file_enc = filename
-        
         codestring = normalizeCode(codestring)
         
         # Check for VCS conflict markers
@@ -249,7 +232,7 @@
                 start, i = conflict.span()
                 lineindex = 1 + codestring.count("\n", 0, start)
                 return [{'error':
-                         (file_enc, lineindex, 0, "",
+                         (filename, lineindex, 0, "",
                           "VCS conflict marker found")
                          }]
         
@@ -259,18 +242,16 @@
             except ImportError:
                 return [{'error': (filename, 0, 0, '',
                         'Quixote plugin not found.')}]
-            template = quixote.ptl_compile.Template(codestring, file_enc)
+            template = quixote.ptl_compile.Template(codestring, filename)
             template.compile()
         else:
             module = builtins.compile(
-                codestring, file_enc, 'exec', ast.PyCF_ONLY_AST)
+                codestring, filename, 'exec', ast.PyCF_ONLY_AST)
     except SyntaxError as detail:
         index = 0
         code = ""
         error = ""
         lines = traceback.format_exception_only(SyntaxError, detail)
-        if sys.version_info[0] == 2:
-            lines = [x.decode(sys.getfilesystemencoding()) for x in lines]
         match = re.match(r'\s*File "(.+)", line (\d+)',
                          lines[0].replace('<string>', filename))
         if match is not None:

eric ide

mercurial