[Python-checkins] gh-104602: Add additional test for listcomp with lambda (#104639)
carljm
webhook-mailer at python.org
Fri May 19 11:16:49 EDT 2023
https://github.com/python/cpython/commit/dbe171e6098fbb96beed81db2c34f6428109e005
commit: dbe171e6098fbb96beed81db2c34f6428109e005
branch: main
author: Jelle Zijlstra <jelle.zijlstra at gmail.com>
committer: carljm <carl at oddbird.net>
date: 2023-05-19T09:16:39-06:00
summary:
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.
files:
M Lib/test/test_listcomps.py
diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py
index 185658ab5a4c..c2cf058c321f 100644
--- a/Lib/test/test_listcomps.py
+++ b/Lib/test/test_listcomps.py
@@ -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]]
More information about the Python-checkins
mailing list