[Python-checkins] bpo-37289: Add a test for if with ifexpr in the peephole optimiser to detect regressions (GH-14127)

Pablo Galindo webhook-mailer at python.org
Thu Jun 20 17:17:07 EDT 2019


https://github.com/python/cpython/commit/1e61504b8b941494f3ac03e0449ddbbba8960175
commit: 1e61504b8b941494f3ac03e0449ddbbba8960175
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-06-20T22:17:03+01:00
summary:

bpo-37289: Add a test for if with ifexpr in the peephole optimiser to detect regressions (GH-14127)

files:
M Lib/test/test_peepholer.py

diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 5d00240e2595..b5f85bd55973 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -421,6 +421,14 @@ def f():
             return 0
         self.assertEqual(f(), 1)
 
+    def test_if_with_if_expression(self):
+        # Check bpo-37289
+        def f(x):
+            if (True if x else False):
+                return True
+            return False
+        self.assertTrue(f(True))
+
 
 class TestBuglets(unittest.TestCase):
 



More information about the Python-checkins mailing list