diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-14 06:13:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 06:13:24 (GMT) |
commit | 7cd581a6bf82309b3c9b9251c54067d442732485 (patch) | |
tree | caf61efc5b45cc164db9d301d600216a63b87df0 /Python | |
parent | 886d83e5aa8df2dd2e93421d2f614438a3244a1c (diff) | |
download | cpython-7cd581a6bf82309b3c9b9251c54067d442732485.zip cpython-7cd581a6bf82309b3c9b9251c54067d442732485.tar.gz cpython-7cd581a6bf82309b3c9b9251c54067d442732485.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.
(cherry picked from commit 05f831865545b08c9a21cfb7773af58b76ec64cb)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
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); |