mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
This allows generators that are using yield from to be seen by debuggers. It also kills the f_yieldfrom field on frame objects. Patch mostly from Mark Shannon with a few tweaks by me.
This commit is contained in:
parent
3270d11d8a
commit
2afe6aeae8
9 changed files with 113 additions and 166 deletions
|
@ -840,9 +840,9 @@ opcode_stack_effect(int opcode, int oparg)
|
|||
case IMPORT_STAR:
|
||||
return -1;
|
||||
case YIELD_VALUE:
|
||||
case YIELD_FROM:
|
||||
return 0;
|
||||
|
||||
case YIELD_FROM:
|
||||
return -1;
|
||||
case POP_BLOCK:
|
||||
return 0;
|
||||
case POP_EXCEPT:
|
||||
|
@ -3323,6 +3323,8 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
|
|||
ADDOP_O(c, LOAD_CONST, Py_None, consts);
|
||||
}
|
||||
if (e->kind == YieldFrom_kind) {
|
||||
ADDOP(c, GET_ITER);
|
||||
ADDOP_O(c, LOAD_CONST, Py_None, consts);
|
||||
ADDOP(c, YIELD_FROM);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue