Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Too wide location info for CHECK_EG_MATCH #129025

@iritkatriel

Description

@iritkatriel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions