diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-06-14 07:18:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 07:18:51 +0100 |
commit | 5292179afc6fd0dc533add054d4790773c9766d0 (patch) | |
tree | 92cb11639e7834233f8d83a112d8d7d0491513f2 /Lib | |
parent | 6a433f5ae63de72a85d20b05ff826c6f72d529b7 (diff) | |
download | cpython-git-5292179afc6fd0dc533add054d4790773c9766d0.tar.gz |
[3.7] bpo-37269: Correctly optimise conditionals with constant booleans (GH-14071) (GH-14073)
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 'Lib')
-rw-r--r-- | Lib/test/test_peepholer.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index 0cc1e92907..1a031544fc 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -311,6 +311,13 @@ class TestTranforms(BytecodeTestCase): self.assertFalse(instr.opname.startswith('BINARY_')) self.assertFalse(instr.opname.startswith('BUILD_')) + def test_condition_with_binop_with_bools(self): + def f(): + if True or False: + return 1 + return 0 + self.assertEqual(f(), 1) + class TestBuglets(unittest.TestCase): |