Skip to content

Commit

Permalink
no cleanup needed if no pushed locals
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Aug 30, 2023
1 parent 4c4eebc commit 8e8b41f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5643,7 +5643,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
ADDOP_I(c, loc, SWAP, PyList_GET_SIZE(state->pushed_locals) + 1);
}

if (c->u->u_nfblocks > 0) {
if (c->u->u_nfblocks > 0 && state->pushed_locals) {
// If we are inside a try block, we need to add our own cleanup handler
// to restore comprehension locals, so they have the correct values
// inside an exception handler or finally block.
Expand Down

0 comments on commit 8e8b41f

Please sign in to comment.