Commits

Anonymous committed bc455fc

+Fix syntax error checking not working with Python 3.

  • Participants
  • Parent commits 815cbe2

Comments (0)

Files changed (2)

File PyStudio/CHANGELOG

 
 +Fix dead object error in GetEditorForFile.
 +Fix error when right clicking in empty area of PyProject window.
++Fix syntax error checking not working with Python 3.
 
 #-----------------------------------------------------------------------------#
 Version 0.7

File PyStudio/PyStudio/SyntaxChecker/CompileChecker.py

         path = data[0]
         err = data[1]
         if err:
-            pat = re.compile("\('.*', ([0-9]+),")
-            matchs = pat.findall(err)
-            if len(matchs) and matchs[0].isdigit():
-                line = max(0, int(matchs[0])-1)
+            line = -1
+
+            # Python 3 outputs correct exception to stderr
+            pat = re.compile('File "(.+)", line ([0-9]+)')
+            matches = pat.findall(err)
+            if len(matches) and len(matches[0]) == 2:
+                match = matches[0]
+                if match[1].isdigit():
+                    line = int(matches[0][1])
+
+            # Python 2 py_compile outputs a tuple of args
+            if line < 0:
+                pat = re.compile("\('.*', ([0-9]+),")
+                matchs = pat.findall(err)
+                if len(matchs) and matchs[0].isdigit():
+                    line = max(0, int(matchs[0])-1)
+
+            if line >= 0:
                 mw = wx.GetApp().GetActiveWindow()
                 buff = PyStudioUtils.GetEditorForFile(mw, path)
                 if buff: