Skip to content
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

Too wide location info for CHECK_EG_MATCH #129025

Open
iritkatriel opened this issue Jan 19, 2025 · 0 comments · May be fixed by #129026
Open

Too wide location info for CHECK_EG_MATCH #129025

iritkatriel opened this issue Jan 19, 2025 · 0 comments · May be fixed by #129026
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@iritkatriel
Copy link
Member

iritkatriel commented Jan 19, 2025

The line number of the instructions emitted for except* (CHECK_EG_MATCH etc) spans the entire except* body, and this shows up in the traceback when except* raises (e.g. when split() fails).

>>> class Bad(ExceptionGroup):
...     def split(*args):
...         1/0
...         
>>> try: raise Bad("", [ValueError(), TypeError()])
... except* ValueError:
...     1
...     2
...     3
...     
  + Exception Group Traceback (most recent call last):
  |   File "<python-input-1>", line 1, in <module>
  |     try: raise Bad("", [ValueError(), TypeError()])
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | Bad:  (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | ValueError
    +---------------- 2 ----------------
    | TypeError
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<python-input-1>", line 2, in <module>
    except* ValueError:
    ...<2 lines>...
        3
  File "<python-input-0>", line 3, in split
    1/0
    ~^~
ZeroDivisionError: division by zero

Linked PRs

iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jan 19, 2025
@tomasr8 tomasr8 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jan 19, 2025
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Jan 19, 2025
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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants