summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-19 16:49:29 (GMT)
committerGitHub <noreply@github.com>2022-05-19 16:49:29 (GMT)
commit3fd86100022103f41ada043f5bb5a7201e80ac27 (patch)
treed57d89cce134d2556a64ea1935117aa2729fedad /Python/compile.c
parent70aa1b9b912d8254df3c61ae0a55464962f4c087 (diff)
downloadcpython-3fd86100022103f41ada043f5bb5a7201e80ac27.zip
cpython-3fd86100022103f41ada043f5bb5a7201e80ac27.tar.gz
cpython-3fd86100022103f41ada043f5bb5a7201e80ac27.tar.bz2
GH-89914: Make the oparg of the YIELD_VALUE instruction equal the stack depth. (GH-92960)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index c42deb5..c862c10 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1962,7 +1962,7 @@ compiler_add_yield_from(struct compiler *c, int await)
compiler_use_next_block(c, start);
ADDOP_JUMP(c, SEND, exit);
compiler_use_next_block(c, resume);
- ADDOP(c, YIELD_VALUE);
+ ADDOP_I(c, YIELD_VALUE, 0);
ADDOP_I(c, RESUME, await ? 3 : 2);
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start);
compiler_use_next_block(c, exit);
@@ -4193,7 +4193,7 @@ addop_yield(struct compiler *c) {
if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) {
ADDOP(c, ASYNC_GEN_WRAP);
}
- ADDOP(c, YIELD_VALUE);
+ ADDOP_I(c, YIELD_VALUE, 0);
ADDOP_I(c, RESUME, 1);
return 1;
}
@@ -7152,6 +7152,9 @@ stackdepth(struct compiler *c, basicblock *entry)
next = NULL;
break;
}
+ if (instr->i_opcode == YIELD_VALUE) {
+ instr->i_oparg = depth;
+ }
}
if (next != NULL) {
assert(b->b_nofallthrough == 0);