Skip to content

Commit bf19b7d

Browse files
committed
Fix invalid bytecode in test_peepholer.DirectCfgOptimizerTests.test_unconditional_jump_threading
Make sure we have a statically known stack depth
1 parent 2af2bbc commit bf19b7d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_peepholer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2264,13 +2264,13 @@ def get_insts(lno1, lno2, op1, op2):
22642264
return [
22652265
lbl2 := self.Label(),
22662266
('LOAD_NAME', 0, 10),
2267+
('POP_TOP', None, 10),
22672268
(op1, lbl1 := self.Label(), lno1),
22682269
('LOAD_NAME', 1, 20),
22692270
lbl1,
22702271
(op2, lbl2, lno2),
22712272
]
22722273

2273-
22742274
for op1 in ('JUMP', 'JUMP_NO_INTERRUPT'):
22752275
for op2 in ('JUMP', 'JUMP_NO_INTERRUPT'):
22762276
# different lines
@@ -2280,6 +2280,7 @@ def get_insts(lno1, lno2, op1, op2):
22802280
op = 'JUMP' if 'JUMP' in (op1, op2) else 'JUMP_NO_INTERRUPT'
22812281
expected_insts = [
22822282
('LOAD_NAME', 0, 10),
2283+
('POP_TOP', None, 10),
22832284
('NOP', None, 4),
22842285
(op, 0, 5),
22852286
]
@@ -2296,6 +2297,7 @@ def get_insts(lno1, lno2, op1, op2):
22962297
op = 'JUMP' if 'JUMP' in (op1, op2) else 'JUMP_NO_INTERRUPT'
22972298
expected_insts = [
22982299
('LOAD_NAME', 0, 10),
2300+
('POP_TOP', None, 10),
22992301
(op, 0, lno),
23002302
]
23012303
self.cfg_optimization_test(insts, expected_insts, consts=list(range(5)))

0 commit comments

Comments
 (0)