Skip to content

Commit 1e61504

Browse files
authored
bpo-37289: Add a test for if with ifexpr in the peephole optimiser to detect regressions (GH-14127)
1 parent c68e3fb commit 1e61504

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_peepholer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ def f():
421421
return 0
422422
self.assertEqual(f(), 1)
423423

424+
def test_if_with_if_expression(self):
425+
# Check bpo-37289
426+
def f(x):
427+
if (True if x else False):
428+
return True
429+
return False
430+
self.assertTrue(f(True))
431+
424432

425433
class TestBuglets(unittest.TestCase):
426434

0 commit comments

Comments
 (0)