mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -2981,7 +2981,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s)
|
|||
return 0;
|
||||
VISIT_SEQ(c, stmt, s->v.Try.finalbody);
|
||||
compiler_pop_fblock(c, FINALLY_END, end);
|
||||
ADDOP(c, RERAISE);
|
||||
ADDOP_I(c, RERAISE, 0);
|
||||
compiler_use_next_block(c, exit);
|
||||
return 1;
|
||||
}
|
||||
|
@ -3107,7 +3107,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
|
|||
compiler_nameop(c, handler->v.ExceptHandler.name, Store);
|
||||
compiler_nameop(c, handler->v.ExceptHandler.name, Del);
|
||||
|
||||
ADDOP(c, RERAISE);
|
||||
ADDOP_I(c, RERAISE, 1);
|
||||
}
|
||||
else {
|
||||
basicblock *cleanup_body;
|
||||
|
@ -3129,7 +3129,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
|
|||
compiler_use_next_block(c, except);
|
||||
}
|
||||
compiler_pop_fblock(c, EXCEPTION_HANDLER, NULL);
|
||||
ADDOP(c, RERAISE);
|
||||
ADDOP_I(c, RERAISE, 0);
|
||||
compiler_use_next_block(c, orelse);
|
||||
VISIT_SEQ(c, stmt, s->v.Try.orelse);
|
||||
compiler_use_next_block(c, end);
|
||||
|
@ -4759,7 +4759,7 @@ compiler_with_except_finish(struct compiler *c) {
|
|||
return 0;
|
||||
ADDOP_JUMP(c, POP_JUMP_IF_TRUE, exit);
|
||||
NEXT_BLOCK(c);
|
||||
ADDOP(c, RERAISE);
|
||||
ADDOP_I(c, RERAISE, 1);
|
||||
compiler_use_next_block(c, exit);
|
||||
ADDOP(c, POP_TOP);
|
||||
ADDOP(c, POP_TOP);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue