]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104602: Add additional test for listcomp with lambda (#104639)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Fri, 19 May 2023 15:16:39 +0000 (08:16 -0700)
committerGitHub <noreply@github.com>
Fri, 19 May 2023 15:16:39 +0000 (09:16 -0600)
This threw a SystemError before #104603. Adding a separate test
because this was a different failure mode than the other two new
tests from #104603, both of which used to segfault.

Lib/test/test_listcomps.py

index 185658ab5a4ca8a1a39278a8aa588befc7d354d2..c2cf058c321fa588cd1b06707e41e44c0e92ee39 100644 (file)
@@ -510,6 +510,16 @@ class ListComprehensionTest(unittest.TestCase):
         """
         self._check_in_scopes(code, {"z": 1, "out": [(3, 2, 1)]})
 
+    def test_lambda_in_iter(self):
+        code = """
+            (func, c), = [(a, b) for b in [1] for a in [lambda : a]]
+            d = func()
+            assert d is func
+            # must use "a" in this scope
+            e = a if False else None
+        """
+        self._check_in_scopes(code, {"c": 1, "e": None})
+
     def test_assign_to_comp_iter_var_in_outer_function(self):
         code = """
             a = [1 for a in [0]]