8000 gh-104602: Add additional test for listcomp with lambda by JelleZijlstra · Pull Request #104639 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104602: Add additional test for listcomp with lambda #104639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-104602: Add additional test for listcomp with lambda
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.
  • Loading branch information
JelleZijlstra committed May 19, 2023
commit e3fa00fb2bdbea9a916fe15eef46d9b25b6113da
10 changes: 10 additions & 0 deletions Lib/test/test_listcomps.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,16 @@ def test_nested_listcomp_in_lambda(self):
"""
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]]
Expand Down
0