mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-98442: fix locations of with statement's cleanup instructions (#120763)
gh-98442: fix location of with statement's cleanup instructions
This commit is contained in:
parent
8bc76ae45f
commit
55596ae044
3 changed files with 38 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue