mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
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.
This commit is contained in:
parent
8a8853af24
commit
dbe171e609
1 changed files with 10 additions and 0 deletions
|
@ -510,6 +510,16 @@ class ListComprehensionTest(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
self._check_in_scopes(code, {"z": 1, "out": [(3, 2, 1)]})
|
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):
|
def test_assign_to_comp_iter_var_in_outer_function(self):
|
||||||
code = """
|
code = """
|
||||||
a = [1 for a in [0]]
|
a = [1 for a in [0]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue