summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/tests
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-01-07 17:30:55 (GMT)
committerVictor Stinner <vstinner@python.org>2020-01-07 17:30:54 (GMT)
commitb821173b5458d137c8d5edb6e9b4997aac800a38 (patch)
treecfce6072acf70326f63889be722ab402d4d36e95 /Lib/lib2to3/tests
parent13a7ee8d62dafe7d2291708312fa2a86e171c7fa (diff)
downloadcpython-b821173b5458d137c8d5edb6e9b4997aac800a38.zip
cpython-b821173b5458d137c8d5edb6e9b4997aac800a38.tar.gz
cpython-b821173b5458d137c8d5edb6e9b4997aac800a38.tar.bz2
bpo-38871: Fix lib2to3 for filter-based statements that contain lambda (GH-17780)
Correctly parenthesize filter-based statements that contain lambda expressions in lib2to3.
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r--Lib/lib2to3/tests/test_fixers.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index 3da5dd8..a285241 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -2954,6 +2954,11 @@ class Test_filter(FixerTestCase):
a = """x = [x for x in range(10) if x%2 == 0]"""
self.check(b, a)
+ # bpo-38871
+ b = """filter(lambda x: True if x > 2 else False, [1, 2, 3])"""
+ a = """[x for x in [1, 2, 3] if (True if x > 2 else False)]"""
+ self.check(b, a)
+
def test_filter_trailers(self):
b = """x = filter(None, 'abc')[0]"""
a = """x = [_f for _f in 'abc' if _f][0]"""