Skip to content

Commit a6f9c5f

Browse files
committed
Yay it mostly works.
1 parent fd254b4 commit a6f9c5f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Python/codegen.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,25 +520,26 @@ codegen_async_yield_from(compiler *c, location loc, expr_ty e)
520520
ADDOP(c, loc, GET_ASYNC_YIELD_FROM_ITER);
521521

522522
USE_LABEL(c, send);
523+
ADDOP_JUMP(c, loc, SETUP_FINALLY, fail);
523524
// Virtual try/except for the StopIteration; see above.
524-
//ADDOP_JUMP(c, loc, SETUP_FINALLY, fail);
525525

526-
// Get the __asend__() and await it
526+
// Get the __asend__() and await it. We preserve the iterator
527+
// on the top of the stack by copying it.
528+
ADDOP_I(c, loc, COPY, 1);
527529
ADDOP_LOAD_CONST(c, loc, Py_None);
528530
ADDOP(c, loc, GET_ASEND);
529531
ADDOP_LOAD_CONST(c, loc, Py_None);
530532
ADD_YIELD_FROM(c, loc, 1);
531533

532-
// Yield the value
533534
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_ASYNC_GEN_WRAP);
534-
ADDOP_I(c, loc, YIELD_VALUE, 0);
535-
ADDOP_I(c, loc, RESUME, RESUME_AFTER_YIELD);
535+
ADDOP_I(c, loc, YIELD_VALUE, 1);
536536

537-
// Repeat the loop
538-
//ADDOP_JUMP(c, loc, JUMP_NO_INTERRUPT, send);
537+
ADDOP(c, NO_LOCATION, POP_BLOCK);
538+
ADDOP(c, loc, POP_TOP);
539+
ADDOP_JUMP(c, loc, JUMP_NO_INTERRUPT, send);
539540

540-
//USE_LABEL(c, fail);
541-
//ADDOP(c, loc, CLEANUP_THROW);
541+
USE_LABEL(c, fail);
542+
ADDOP(c, loc, POP_TOP);
542543

543544
return SUCCESS;
544545
}

0 commit comments

Comments
 (0)