Skip to content

PythonConsoleLexer has broken traceback highlighting if no module location provided in traceback #2226

@dbader

Description

@dbader

Example 1 (broken)

Input:

>>> exec('"')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    "
     ^
SyntaxError: EOL while scanning string literal

Result:
Screen Shot 2022-09-09 at 4 54 46 PM

👆 Notice the two missing lines in the output, starting with the Traceback (most recent call last): line. This is a "real" traceback generated by the Python 3.9 REPL.

Example 2 (okay)

Adding a module location to the 2nd file location (, in <module>) restores the missing "Traceback ..." line and renders as expected:

>>> exec('"')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
    "
     ^
SyntaxError: EOL while scanning string literal

Result:
Screen Shot 2022-09-09 at 4 56 35 PM

Adding a comma (,) after the 2nd File "<string>", line 1 is enough to make the "Traceback ..." line appear (although it won't get the correct highlighting):

Screen Shot 2022-09-09 at 4 59 47 PM

Versions

Metadata

Metadata

Assignees

Labels

S-majorseverity: majorT-bugtype: a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions