Skip to content

Traceback formatting issue: SyntaxError and ExceptionGroup #111334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobolevn opened this issue Oct 25, 2023 · 1 comment
Closed

Traceback formatting issue: SyntaxError and ExceptionGroup #111334

sobolevn opened this issue Oct 25, 2023 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Oct 25, 2023

Bug report

When raising SyntaxError with ExceptionGroup the traceback formatting seems to be broken:

>>> e = SyntaxError("error", ("x.py", 23, None, "bad syntax"))
>>> raise ExceptionGroup('A', [e])
  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  | ExceptionGroup: A (1 sub-exception)
  +-+---------------- 1 ----------------
    |   File "x.py", line 23
    bad syntax
    | SyntaxError: error
    +------------------------------------

Note that bad syntax is not properly prefixed by | and not indented properly.

Compare it with:

>>> raise e
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "x.py", line 23
    bad syntax
SyntaxError: error

I expect it to be:

  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  | ExceptionGroup: A (1 sub-exception)
  +-+---------------- 1 ----------------
    |   File "x.py", line 23
    |     bad syntax
    | SyntaxError: error
    +------------------------------------

This causes some side-effects on my work in #104150
So, I've prepared a PR to fix it. Polishing it and send today / tomorrow.

CC @iritkatriel

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 25, 2023
@sobolevn sobolevn self-assigned this Oct 25, 2023
@sobolevn
Copy link
Member Author

It is fixed on main, but not on 3.11.5.
This is the second time today I run a different python version 😒

@sobolevn sobolevn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant