Skip to content

Commit dbe171e

Browse files
gh-104602: Add additional test for listcomp with lambda (#104639)
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.
1 parent 8a8853a commit dbe171e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_listcomps.py

+10
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ def test_nested_listcomp_in_lambda(self):
510510
"""
511511
self._check_in_scopes(code, {"z": 1, "out": [(3, 2, 1)]})
512512

513+
def test_lambda_in_iter(self):
514+
code = """
515+
(func, c), = [(a, b) for b in [1] for a in [lambda : a]]
516+
d = func()
517+
assert d is func
518+
# must use "a" in this scope
519+
e = a if False else None
520+
"""
521+
self._check_in_scopes(code, {"c": 1, "e": None})
522+
513523
def test_assign_to_comp_iter_var_in_outer_function(self):
514524
code = """
515525
a = [1 for a in [0]]

0 commit comments

Comments
 (0)