@@ -540,6 +540,7 @@ codegen_unwind_fblock(compiler *c, location *ploc,
540540 case COMPILE_FBLOCK_EXCEPTION_HANDLER :
541541 case COMPILE_FBLOCK_EXCEPTION_GROUP_HANDLER :
542542 case COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR :
543+ case COMPILE_FBLOCK_INLINED_COMPREHENSION :
543544 case COMPILE_FBLOCK_STOP_ITERATION :
544545 return SUCCESS ;
545546
@@ -4873,8 +4874,11 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc,
48734874 NEW_JUMP_TARGET_LABEL (c , cleanup );
48744875 state -> cleanup = cleanup ;
48754876
4876- // no need to push an fblock for this "virtual" try/finally; there can't
4877- // be return/continue/break inside a comprehension
4877+ // Count against CO_MAXBLOCKS: SETUP_FINALLY consumes an except-stack
4878+ // slot even though return/continue/break cannot appear here.
4879+ RETURN_IF_ERROR (_PyCompile_PushFBlock (
4880+ c , loc , COMPILE_FBLOCK_INLINED_COMPREHENSION ,
4881+ cleanup , NO_LABEL , NULL ));
48784882 ADDOP_JUMP (c , loc , SETUP_FINALLY , cleanup );
48794883 }
48804884 return SUCCESS ;
@@ -4920,6 +4924,8 @@ codegen_pop_inlined_comprehension_locals(compiler *c, location loc,
49204924{
49214925 if (state -> pushed_locals ) {
49224926 ADDOP (c , NO_LOCATION , POP_BLOCK );
4927+ _PyCompile_PopFBlock (c , COMPILE_FBLOCK_INLINED_COMPREHENSION ,
4928+ state -> cleanup );
49234929
49244930 NEW_JUMP_TARGET_LABEL (c , end );
49254931 ADDOP_JUMP (c , NO_LOCATION , JUMP_NO_INTERRUPT , end );
0 commit comments