gh-104404: fix crasher with nested comprehensions plus lambdas (#104442)

This commit is contained in:
Carl Meyer 2023-05-12 18:42:04 -06:00 committed by GitHub
parent 1eb950ca55
commit 563c7dcba0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View file

@ -338,6 +338,14 @@ class ListComprehensionTest(unittest.TestCase):
outputs = {"y": [1, 3, 5]}
self._check_in_scopes(code, outputs)
def test_nested_4(self):
code = """
items = [([lambda: x for x in range(2)], lambda: x) for x in range(3)]
out = [([fn() for fn in fns], fn()) for fns, fn in items]
"""
outputs = {"out": [([1, 1], 2), ([1, 1], 2), ([1, 1], 2)]}
self._check_in_scopes(code, outputs)
def test_nameerror(self):
code = """
[x for x in [1]]