diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 48f419e62fbbed..19de501a7b9866 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -1408,6 +1408,28 @@ def test_pdb_issue_gh_91742(): Author: 'pi' Version: '3.14' """ +def test_pdb_issue_gh_101517(): + """See GH-101517 + + breakpoint in except* clause + + >>> def test_function(): + ... try: + ... raise ExceptionGroup("eg", [KeyError(), ValueError()]) + ... except* KeyError: + ... breakpoint() + ... + >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE + ... 'continue' + ... ]): + ... try: + ... test_function() + ... except Exception as e: + ... print(repr(e)) + ExceptionGroup('eg', [ValueError()]) + >>> + """ + def test_pdb_issue_gh_94215(): """See GH-94215 diff --git a/Python/compile.c b/Python/compile.c index d9ec68958972b5..1d78c326890ad3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3747,9 +3747,10 @@ compiler_try_star_except(struct compiler *c, stmt_ty s) USE_LABEL(c, except); if (i == n - 1) { + loc = location_of_last_executing_statement(handler->v.ExceptHandler.body); /* Add exc to the list (if not None it's the unhandled part of the EG) */ - ADDOP_I(c, NO_LOCATION, LIST_APPEND, 1); - ADDOP_JUMP(c, NO_LOCATION, JUMP, reraise_star); + ADDOP_I(c, loc, LIST_APPEND, 1); + ADDOP_JUMP(c, loc, JUMP, reraise_star); } } /* artificial */