diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-06-14 05:54:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 05:54:53 (GMT) |
commit | 05f831865545b08c9a21cfb7773af58b76ec64cb (patch) | |
tree | 439a8f94ee9aca75bf386902ace8b04eaa8fa0e9 /Python | |
parent | d0eeb936d8daf05d7d89f6935e3f4c0dee49c5be (diff) | |
download | cpython-05f831865545b08c9a21cfb7773af58b76ec64cb.zip cpython-05f831865545b08c9a21cfb7773af58b76ec64cb.tar.gz cpython-05f831865545b08c9a21cfb7773af58b76ec64cb.tar.bz2 |
bpo-37269: Correctly optimise conditionals with constant booleans (GH-14071)
Fix a regression introduced by af8646c8054d0f4180a2013383039b6a472f9698 that was causing code of the form:
if True and False:
do_something()
to be optimized incorrectly, eliminating the block.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/peephole.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/peephole.c b/Python/peephole.c index 6f3e2ed..d7b1dfc 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -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); |