Skip to content

Commit ad9bc3a

Browse files
committed
Correctly handle SyntaxError tracebacks
These don't include the `, in codeblock` text, they just end. This replicates the original non-regex workflow. The tooltip for these links in workboxes now includes the workbox name.
1 parent b7045f3 commit ad9bc3a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

preditor/gui/console.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def __init__(self, parent):
5959
pattern += r'line (?P<lineNum>\d{1,6}), in'
6060
self.workbox_pattern = re.compile(pattern)
6161

62-
# Define a pattern to capture info from tracebacks
63-
pattern = r'File "(?P<filename>.*)", line (?P<lineNum>\d{1,10}), in'
62+
# Define a pattern to capture info from tracebacks. The newline/$ section
63+
# handle SyntaxError output that does not include the `, in ...` portion.
64+
pattern = r'File "(?P<filename>.*)", line (?P<lineNum>\d{1,10})(, in|\r\n|\n|$)'
6465
self.traceback_pattern = re.compile(pattern)
6566

6667
self._consolePrompt = '>>> '
@@ -989,6 +990,7 @@ def write(self, msg, error=False):
989990
fileEnd = info.get("fileEnd")
990991
lineNum = info.get("lineNum")
991992

993+
toolTip = 'Open "{}" at line number {}'.format(filename, lineNum)
992994
if isWorkbox:
993995
split = filename.split(':')
994996
workboxIdx = split[-1]
@@ -1006,7 +1008,6 @@ def write(self, msg, error=False):
10061008
fmt.setAnchor(True)
10071009
fmt.setAnchorHref(href)
10081010
fmt.setFontUnderline(True)
1009-
toolTip = "Open {} at line number {}".format(filename, lineNum)
10101011
fmt.setToolTip(toolTip)
10111012
cursor.insertText(msg[fileStart:fileEnd], fmt)
10121013

0 commit comments

Comments
 (0)