python / python/cpython

Too wide location info for CHECK_EG_MATCH

Open
#129,025 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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
  • gh-129026

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the traceback with the except* and Bad.split() example in the issue, then inspect linked PR gh-129026 for the implementation context. Done means the CHECK_EG_MATCH location no longer spans the entire except* body and the shown traceback remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.