Skip to content

Commit 81fecf7

Browse files
bpo-37289: Remove 'if False' handling in the peephole optimizer (GH-14099) (GH-14111)
(cherry picked from commit 7a68f8c) Co-authored-by: Pablo Galindo <[email protected]>
1 parent d799fd3 commit 81fecf7

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
@@ -309,18 +309,12 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
309309
}
310310
PyObject* cnt = PyList_GET_ITEM(consts, get_arg(codestr, i));
311311
int is_true = PyObject_IsTrue(cnt);
312+
if (is_true == -1) {
313+
goto exitError;
314+
}
312315
if (is_true == 1) {
313316
fill_nops(codestr, op_start, nexti + 1);
314317
cumlc = 0;
315-
} else if (is_true == 0) {
316-
if (i > 1 &&
317-
(_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_TRUE ||
318-
_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_FALSE)) {
319-
break;
320-
}
321-
h = get_arg(codestr, nexti) / sizeof(_Py_CODEUNIT);
322-
tgt = find_op(codestr, codelen, h);
323-
fill_nops(codestr, op_start, tgt);
324318
}
325319
break;
326320

0 commit comments

Comments
 (0)