mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-37269: Correctly optimise conditionals with constant booleans (GH-14071)
Fix a regression introduced byaf8646c805
that was causing code of the form: if True and False: do_something() to be optimized incorrectly, eliminating the block. (cherry picked from commit05f8318655
) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
886d83e5aa
commit
7cd581a6bf
3 changed files with 14 additions and 0 deletions
|
@ -315,6 +315,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
|||
fill_nops(codestr, op_start, nexti + 1);
|
||||
cumlc = 0;
|
||||
} else if (is_true == 0) {
|
||||
if (i > 1 &&
|
||||
(_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_TRUE ||
|
||||
_Py_OPCODE(codestr[i - 1]) == POP_JUMP_IF_FALSE)) {
|
||||
break;
|
||||
}
|
||||
h = get_arg(codestr, nexti) / sizeof(_Py_CODEUNIT);
|
||||
tgt = find_op(codestr, codelen, h);
|
||||
fill_nops(codestr, op_start, tgt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue