@@ -4765,40 +4765,16 @@ codegen_sync_comprehension_generator(compiler *c, location loc,
47654765}
47664766
47674767static int
4768- codegen_async_comprehension_generator ( compiler * c , location loc ,
4769- asdl_comprehension_seq * generators ,
4770- int gen_index , int depth ,
4771- expr_ty elt , expr_ty val , int type ,
4772- IterStackPosition iter_pos , bool avoid_creation )
4768+ codegen_async_comprehension_generator_body (
4769+ compiler * c , location loc ,
4770+ asdl_comprehension_seq * generators , int gen_index , int depth ,
4771+ expr_ty elt , expr_ty val , int type , bool avoid_creation ,
4772+ comprehension_ty gen , jump_target_label start )
47734773{
4774- NEW_JUMP_TARGET_LABEL (c , start );
47754774 NEW_JUMP_TARGET_LABEL (c , send );
47764775 NEW_JUMP_TARGET_LABEL (c , except );
47774776 NEW_JUMP_TARGET_LABEL (c , if_cleanup );
4778-
4779- comprehension_ty gen = (comprehension_ty )asdl_seq_GET (generators ,
4780- gen_index );
4781-
4782- if (iter_pos == ITERABLE_IN_LOCAL ) {
4783- if (gen_index == 0 ) {
4784- assert (METADATA (c )-> u_argcount == 1 );
4785- ADDOP_I (c , loc , LOAD_FAST , 0 );
4786- }
4787- else {
4788- /* Sub-iter - calculate on the fly */
4789- VISIT (c , expr , gen -> iter );
4790- }
4791- }
4792- if (iter_pos != ITERATOR_ON_STACK ) {
4793- ADDOP (c , LOC (gen -> iter ), GET_AITER );
4794- }
4795-
47964777 USE_LABEL (c , start );
4797- /* Runtime will push a block here, so we need to account for that */
4798- RETURN_IF_ERROR (
4799- _PyCompile_PushFBlock (c , loc , COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR ,
4800- start , NO_LABEL , NULL ));
4801-
48024778 ADDOP_JUMP (c , loc , SETUP_FINALLY , except );
48034779 ADDOP (c , loc , GET_ANEXT );
48044780 ADDOP (c , loc , PUSH_NULL );
@@ -4907,15 +4883,51 @@ codegen_async_comprehension_generator(compiler *c, location loc,
49074883 USE_LABEL (c , if_cleanup );
49084884 ADDOP_JUMP (c , elt_loc , JUMP , start );
49094885
4910- _PyCompile_PopFBlock (c , COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR , start );
4911-
49124886 USE_LABEL (c , except );
49134887
49144888 ADDOP_JUMP (c , loc , END_ASYNC_FOR , send );
49154889
49164890 return SUCCESS ;
49174891}
49184892
4893+ static int
4894+ codegen_async_comprehension_generator (compiler * c , location loc ,
4895+ asdl_comprehension_seq * generators ,
4896+ int gen_index , int depth ,
4897+ expr_ty elt , expr_ty val , int type ,
4898+ IterStackPosition iter_pos , bool avoid_creation )
4899+ {
4900+ NEW_JUMP_TARGET_LABEL (c , start );
4901+
4902+ comprehension_ty gen = (comprehension_ty )asdl_seq_GET (generators ,
4903+ gen_index );
4904+
4905+ if (iter_pos == ITERABLE_IN_LOCAL ) {
4906+ if (gen_index == 0 ) {
4907+ assert (METADATA (c )-> u_argcount == 1 );
4908+ ADDOP_I (c , loc , LOAD_FAST , 0 );
4909+ }
4910+ else {
4911+ /* Sub-iter - calculate on the fly */
4912+ VISIT (c , expr , gen -> iter );
4913+ }
4914+ }
4915+ if (iter_pos != ITERATOR_ON_STACK ) {
4916+ ADDOP (c , LOC (gen -> iter ), GET_AITER );
4917+ }
4918+
4919+ /* Runtime will push a block here, so we need to account for that */
4920+ RETURN_IF_ERROR (
4921+ _PyCompile_PushFBlock (c , loc , COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR ,
4922+ start , NO_LABEL , NULL ));
4923+
4924+ int ret = codegen_async_comprehension_generator_body (
4925+ c , loc , generators , gen_index , depth , elt , val , type , avoid_creation ,
4926+ gen , start );
4927+ _PyCompile_PopFBlock (c , COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR , start );
4928+ return ret ;
4929+ }
4930+
49194931static int
49204932codegen_push_inlined_comprehension_locals (compiler * c , location loc ,
49214933 PySTEntryObject * comp ,
0 commit comments