8000 increment g_maxdepth when adding RETURN_GENERATOR (matches previous s… · iritkatriel/cpython@1cea1e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cea1e4

Browse files
committed
increment g_maxdepth when adding RETURN_GENERATOR (matches previous stackdepth)
1 parent 962e87c commit 1cea1e4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Python/compile.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7528,17 +7528,15 @@ build_cellfixedoffsets(_PyCompile_CodeUnitMetadata *umd)
75287528
}
75297529

75307530
static int
7531-
insert_prefix_instructions(_PyCompile_CodeUnitMetadata *umd, basicblock *entryblock,
7531+
insert_prefix_instructions(_PyCompile_CodeUnitMetadata *umd, cfg_builder *g,
75327532
int *fixed, int nfreevars, int code_flags)
75337533
{
7534+
basicblock *entryblock = g->g_entryblock;
75347535
assert(umd->u_firstlineno > 0);
75357536

75367537
/* Add the generator prefix instructions. */
75377538
if (code_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR)) {
7538-
/* Note that RETURN_GENERATOR + POP_TOP have a net stack effect
7539-
* of 0. This is because RETURN_GENERATOR pushes an element
7540-
* with _PyFrame_StackPush before switching stacks.
7541-
*/
7539+
g->g_maxdepth++; /* make space for the value pushed by RETURN_GENERATOR */
75427540
cfg_instr make_gen = {
75437541
.i_opcode = RETURN_GENERATOR,
75447542
.i_oparg = 0,
@@ -7669,7 +7667,7 @@ prepare_localsplus(_PyCompile_CodeUnitMetadata *umd, cfg_builder *g, int code_fl
76697667

76707668

76717669
// This must be called before fix_cell_offsets().
7672-
if (insert_prefix_instructions(umd, g->g_entryblock, cellfixedoffsets, nfreevars, code_flags)) {
7670+
if (insert_prefix_instructions(umd, g, cellfixedoffsets, nfreevars, code_flags)) {
76737671
PyMem_Free(cellfixedoffsets);
76747672
return ERROR;
76757673
}

0 commit comments

Comments
 (0)
0