diff options
author | Mark Shannon <mark@hotpy.org> | 2020-12-17 13:55:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 13:55:28 +0000 |
commit | bf353f3c2d937772a8cf30b15fd8eb7b82665ccb (patch) | |
tree | 9196732769c1cca2bd01a44e668fe4c5fb29f7d7 /Python/ceval.c | |
parent | bpo-26564: fix obsolete comment in traceback.c (GH-23819) (diff) | |
download | cpython-bf353f3c2d937772a8cf30b15fd8eb7b82665ccb.tar.gz cpython-bf353f3c2d937772a8cf30b15fd8eb7b82665ccb.tar.bz2 cpython-bf353f3c2d937772a8cf30b15fd8eb7b82665ccb.zip |
bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly after raising or reraising an exception (GH-23803)
* Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626.
* Update importlib
* Add NEWS.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 9de925780e4..f0f39539c97 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2430,6 +2430,10 @@ main_loop: } case TARGET(RERAISE): { + assert(f->f_iblock > 0); + if (oparg) { + f->f_lasti = f->f_blockstack[f->f_iblock-1].b_handler; + } PyObject *exc = POP(); PyObject *val = POP(); PyObject *tb = POP(); @@ -4039,7 +4043,7 @@ exception_unwind: int handler = b->b_handler; _PyErr_StackItem *exc_info = tstate->exc_info; /* Beware, this invalidates all b->b_* fields */ - PyFrame_BlockSetup(f, EXCEPT_HANDLER, -1, STACK_LEVEL()); + PyFrame_BlockSetup(f, EXCEPT_HANDLER, f->f_lasti, STACK_LEVEL()); PUSH(exc_info->exc_traceback); PUSH(exc_info->exc_value); if (exc_info->exc_type != NULL) { |