@@ -1955,37 +1955,36 @@ compiler_call_exit_with_nones(struct compiler *c) {
19551955static int
19561956compiler_add_yield_from (struct compiler * c , int await )
19571957{
1958- basicblock * start , * resume , * stopiter , * error , * exit ;
1958+ basicblock * start , * resume , * error , * stopiter , * exit ;
19591959 RETURN_IF_FALSE (start = compiler_new_block (c ));
19601960 RETURN_IF_FALSE (resume = compiler_new_block (c ));
1961- RETURN_IF_FALSE (stopiter = compiler_new_block (c ));
19621961 RETURN_IF_FALSE (error = compiler_new_block (c ));
1962+ RETURN_IF_FALSE (stopiter = compiler_new_block (c ));
19631963 RETURN_IF_FALSE (exit = compiler_new_block (c ));
19641964 compiler_use_next_block (c , start );
19651965 ADDOP_JUMP (c , SEND , exit );
19661966 compiler_use_next_block (c , resume );
19671967 // Set up a virtual try/except to handle StopIteration raised during a
19681968 // close() or throw():
1969- ADDOP_JUMP (c , SETUP_FINALLY , stopiter );
1969+ ADDOP_JUMP (c , SETUP_FINALLY , error );
19701970 RETURN_IF_FALSE (compiler_push_fblock (c , TRY_EXCEPT , resume , NULL , NULL ));
19711971 // The only way YIELD_VALUE can raise is if close() or throw() raises:
19721972 ADDOP (c , YIELD_VALUE );
19731973 compiler_pop_fblock (c , TRY_EXCEPT , resume );
19741974 ADDOP_NOLINE (c , POP_BLOCK );
19751975 ADDOP_I (c , RESUME , await ? 3 : 2 );
19761976 ADDOP_JUMP (c , JUMP_NO_INTERRUPT , start );
1977- compiler_use_next_block (c , stopiter );
1977+ compiler_use_next_block (c , error );
19781978 ADDOP_I (c , LOAD_EXCEPTION_TYPE , 1 ); // StopIteration
19791979 ADDOP (c , CHECK_EXC_MATCH );
1980- ADDOP_JUMP (c , POP_JUMP_IF_FALSE , error );
1980+ ADDOP_JUMP (c , POP_JUMP_IF_TRUE , stopiter );
1981+ ADDOP_I (c , RERAISE , 0 );
1982+ compiler_use_next_block (c , stopiter );
19811983 // StopIteration was raised. Push the return value and continue execution:
19821984 ADDOP_NAME (c , LOAD_ATTR , & _Py_ID (value ), names );
19831985 ADDOP_I (c , SWAP , 3 );
19841986 ADDOP (c , POP_TOP );
19851987 ADDOP (c , POP_TOP );
1986- ADDOP_JUMP (c , JUMP , exit );
1987- compiler_use_next_block (c , error );
1988- ADDOP_I (c , RERAISE , 0 );
19891988 compiler_use_next_block (c , exit );
19901989 return 1 ;
19911990}
0 commit comments