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/compile.c | |
parent | 40125ab3252453bf205ed906e46bf9741c27bf9d (diff) | |
download | cpython-git-bf353f3c2d937772a8cf30b15fd8eb7b82665ccb.tar.gz |
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/compile.c')
-rw-r--r-- | Python/compile.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c index 2871ffc476..d4dbaf7b6a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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); |