Skip to content

Commit 7a68f8c

Browse files
authored
bpo-37289: Remove 'if False' handling in the peephole optimizer (GH-14099)
1 parent cfa0394 commit 7a68f8c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Python/peephole.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,12 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
311311
}
312312
PyObject* cnt = PyList_GET_ITEM(consts, get_arg(codestr, i));
313313
int is_true = PyObject_IsTrue(cnt);
314+
if (is_true == -1) {
315+
goto exitError;
316+
}
314317
if (is_true == 1) {
315318
fill_nops(codestr, op_start, nexti + 1);
316319
cumlc = 0;
317-
} else if (is_true == 0) {
318-
if (i > 1 &&
319-
(_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_TRUE ||
320-
_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_FALSE)) {
321-
break;
322-
}
323-
h = get_arg(codestr, nexti) / sizeof(_Py_CODEUNIT);
324-
tgt = find_op(codestr, codelen, h);
325-
fill_nops(codestr, op_start, tgt);
326320
}
327321
break;
328322

0 commit comments

Comments
 (0)