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 /Lib/test/test_peepholer.py | |
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 'Lib/test/test_peepholer.py')
-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 860ceeb..5d00240 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -414,6 +414,13 @@ class TestTranforms(BytecodeTestCase): pass self.assertEqual(count_instr_recursively(forloop, 'BUILD_LIST'), 0) + 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): |