diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2023-05-19 15:16:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-19 15:16:39 (GMT) |
commit | dbe171e6098fbb96beed81db2c34f6428109e005 (patch) | |
tree | 49b14895597b2d74fffa860673fbdd8da1db409f | |
parent | 8a8853af24b41a73653d07dcc2f44d05b10e0673 (diff) | |
download | cpython-dbe171e6098fbb96beed81db2c34f6428109e005.zip cpython-dbe171e6098fbb96beed81db2c34f6428109e005.tar.gz cpython-dbe171e6098fbb96beed81db2c34f6428109e005.tar.bz2 |
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.
-rw-r--r-- | Lib/test/test_listcomps.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index 185658a..c2cf058 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -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]] |