Skip to content

Commit d738164

Browse files
committed
pythongh-101517: Fix missing linenumber for re-raise in except*
1 parent a687ae9 commit d738164

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Diff for: Lib/test/test_pdb.py

+22
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,28 @@ def test_pdb_issue_gh_91742():
14081408
Author: 'pi' Version: '3.14'
14091409
"""
14101410

1411+
def test_pdb_issue_gh_101517():
1412+
"""See GH-101517
1413+
1414+
breakpoint in except* clause
1415+
1416+
>>> def test_function():
1417+
... try:
1418+
... raise ExceptionGroup("eg", [KeyError(), ValueError()])
1419+
... except* KeyError:
1420+
... breakpoint()
1421+
...
1422+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
1423+
... 'continue'
1424+
... ]):
1425+
... try:
1426+
... test_function()
1427+
... except Exception as e:
1428+
... print(repr(e))
1429+
ExceptionGroup('eg', [ValueError()])
1430+
>>>
1431+
"""
1432+
14111433
def test_pdb_issue_gh_94215():
14121434
"""See GH-94215
14131435

Diff for: Python/compile.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3747,9 +3747,10 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
37473747
USE_LABEL(c, except);
37483748

37493749
if (i == n - 1) {
3750+
loc = location_of_last_executing_statement(handler->v.ExceptHandler.body);
37503751
/* Add exc to the list (if not None it's the unhandled part of the EG) */
3751-
ADDOP_I(c, NO_LOCATION, LIST_APPEND, 1);
3752-
ADDOP_JUMP(c, NO_LOCATION, JUMP, reraise_star);
3752+
ADDOP_I(c, loc, LIST_APPEND, 1);
3753+
ADDOP_JUMP(c, loc, JUMP, reraise_star);
37533754
}
37543755
}
37553756
/* artificial */

0 commit comments

Comments
 (0)