mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319)
This fixes a regression that was introduced by the new parser. Automerge-Triggered-By: GH:lysnikolaou
This commit is contained in:
parent
f62dad16b8
commit
cb3e5ed071
4 changed files with 18 additions and 7 deletions
|
@ -513,6 +513,15 @@ spam()"""
|
|||
self.assertEqual(nonlocal_var, None)
|
||||
f()
|
||||
|
||||
def test_named_expression_scope_in_genexp(self):
|
||||
a = 1
|
||||
b = [1, 2, 3, 4]
|
||||
genexp = (c := i + a for i in b)
|
||||
|
||||
self.assertNotIn("c", locals())
|
||||
for idx, elem in enumerate(genexp):
|
||||
self.assertEqual(elem, b[idx] + a)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue