summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-06-20 08:32:06 (GMT)
committerGitHub <noreply@github.com>2024-06-20 08:32:06 (GMT)
commit55596ae0446e40f47e2a28b8897fe9530c32a19a (patch)
tree9af7268db663c94d53fce5a557ff96df1b5192f4 /Python
parent8bc76ae45f48bede7ce3191db08cf36d879e6e8d (diff)
downloadcpython-55596ae0446e40f47e2a28b8897fe9530c32a19a.zip
cpython-55596ae0446e40f47e2a28b8897fe9530c32a19a.tar.gz
cpython-55596ae0446e40f47e2a28b8897fe9530c32a19a.tar.bz2
gh-98442: fix locations of with statement's cleanup instructions (#120763)
gh-98442: fix location of with statement's cleanup instructions
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 50b542d..9a81b8b 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -119,6 +119,7 @@ enum fblocktype { WHILE_LOOP, FOR_LOOP, TRY_EXCEPT, FINALLY_TRY, FINALLY_END,
struct fblockinfo {
enum fblocktype fb_type;
jump_target_label fb_block;
+ location fb_loc;
/* (optional) type-specific exit or cleanup block */
jump_target_label fb_exit;
/* (optional) additional information required for unwinding */
@@ -1239,6 +1240,7 @@ compiler_push_fblock(struct compiler *c, location loc,
f = &c->u->u_fblock[c->u->u_nfblocks++];
f->fb_type = t;
f->fb_block = block_label;
+ f->fb_loc = loc;
f->fb_exit = exit;
f->fb_datum = datum;
return SUCCESS;
@@ -1366,7 +1368,7 @@ compiler_unwind_fblock(struct compiler *c, location *ploc,
case WITH:
case ASYNC_WITH:
- *ploc = LOC((stmt_ty)info->fb_datum);
+ *ploc = info->fb_loc;
ADDOP(c, *ploc, POP_BLOCK);
if (preserve_tos) {
ADDOP_I(c, *ploc, SWAP, 3);