mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.
This commit is contained in:
parent
40125ab325
commit
bf353f3c2d
13 changed files with 317 additions and 225 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue