Skip to content

Commit 07438f6

Browse files
Fix a stack level bug
1 parent 77a425c commit 07438f6

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

Lib/test/test_capi/test_opt.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,6 @@ def testfunc(n, m):
474474
uops = get_opnames(ex)
475475
self.assertIn("_FOR_ITER_TIER_TWO", uops)
476476

477-
def test_for_iter_dict_items(self):
478-
479-
def testfunc(n):
480-
dct = dict(zip(range(n), range(n, -1, - 1))).items()
481-
for k, v in dct:
482-
pass
483-
484-
testfunc(TIER2_THRESHOLD)
485-
ex = get_first_executor(testfunc)
486-
self.assertIsNotNone(ex)
487-
uops = get_opnames(ex)
488-
489-
self.assertIn("_GUARD_NOT_EXHAUSTED_DICT_ITEMS", uops)
490-
491477

492478

493479
@requires_specialization

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,13 @@ dummy_func(void) {
10651065
REPLACE_OP((this_instr + 2), _NOP, 0, 0);
10661066
REPLACE_OP((this_instr + 3), _NOP, 0, 0);
10671067
REPLACE_OP((this_instr + 4), _NOP, 0, 0);
1068+
// We need to move forward to the state of _UNPACK_SEQUENCE_TWO_TUPLE
1069+
CHECK_STACK_BOUNDS(2);
1070+
stack_pointer[0] = sym_new_not_null(ctx);
1071+
stack_pointer[1] = sym_new_not_null(ctx);
1072+
stack_pointer += 2;
1073+
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
1074+
break;
10681075
}
10691076
next = sym_new_not_null(ctx);
10701077
}

Python/optimizer_cases.c.h

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)