@@ -527,6 +527,7 @@ codegen_unwind_fblock(compiler *c, location *ploc,
527527 case COMPILE_FBLOCK_EXCEPTION_HANDLER :
528528 case COMPILE_FBLOCK_EXCEPTION_GROUP_HANDLER :
529529 case COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR :
530+ case COMPILE_FBLOCK_INLINED_COMPREHENSION :
530531 case COMPILE_FBLOCK_STOP_ITERATION :
531532 return SUCCESS ;
532533
@@ -4685,8 +4686,11 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc,
46854686 NEW_JUMP_TARGET_LABEL (c , cleanup );
46864687 state -> cleanup = cleanup ;
46874688
4688- // no need to push an fblock for this "virtual" try/finally; there can't
4689- // be return/continue/break inside a comprehension
4689+ // Count against CO_MAXBLOCKS: SETUP_FINALLY consumes an except-stack
4690+ // slot even though return/continue/break cannot appear here.
4691+ RETURN_IF_ERROR (_PyCompile_PushFBlock (
4692+ c , loc , COMPILE_FBLOCK_INLINED_COMPREHENSION ,
4693+ cleanup , NO_LABEL , NULL ));
46904694 ADDOP_JUMP (c , loc , SETUP_FINALLY , cleanup );
46914695 }
46924696 return SUCCESS ;
@@ -4732,6 +4736,8 @@ codegen_pop_inlined_comprehension_locals(compiler *c, location loc,
47324736{
47334737 if (state -> pushed_locals ) {
47344738 ADDOP (c , NO_LOCATION , POP_BLOCK );
4739+ _PyCompile_PopFBlock (c , COMPILE_FBLOCK_INLINED_COMPREHENSION ,
4740+ state -> cleanup );
47354741
47364742 NEW_JUMP_TARGET_LABEL (c , end );
47374743 ADDOP_JUMP (c , NO_LOCATION , JUMP_NO_INTERRUPT , end );
0 commit comments