From 03264e2c99b97f4aff72281731605edc311c9eab Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sun, 16 Jun 2019 12:42:51 +0100 Subject: [PATCH 1/2] bpo-37289: Add a test for if with ifexpr in the peephole optimizer to detect regressions --- Lib/test/test_peepholer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index 5d00240e2595a8..d4afc29addaf68 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(): + if True if f.__code__ else None: + return True + return False + self.assertTrue(f()) + class TestBuglets(unittest.TestCase): From 860c7c67cffabec1bee29fec2280e0ad12cf3651 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sun, 16 Jun 2019 23:39:44 +0100 Subject: [PATCH 2/2] fixup! bpo-37289: Add a test for if with ifexpr in the peephole optimizer to detect regressions --- Lib/test/test_peepholer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index d4afc29addaf68..b5f85bd5597342 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -423,11 +423,11 @@ def f(): def test_if_with_if_expression(self): # Check bpo-37289 - def f(): - if True if f.__code__ else None: + def f(x): + if (True if x else False): return True return False - self.assertTrue(f()) + self.assertTrue(f(True)) class TestBuglets(unittest.TestCase): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy