You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unparenthesized walrus is not allowed in genexps #86540
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2020-11-16.23:39:39.790>created_at=<Date2020-11-16.17:43:28.572>labels= ['interpreter-core', 'type-bug', '3.9', '3.10']
title='Unparenthesized walrus is not allowed in genexps'updated_at=<Date2020-11-16.23:39:39.789>user='https://github.com/lysnikolaou'
While a walrus is valid withing generator expressions in 3.8, it's not in 3.9 and onward.
➜ cpython git:(master) ✗ python3.8
Python 3.8.6 (default, Oct 3 2020, 16:26:47)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> i =2
>>> a = [1, 2, 3, 4]
>>> (b := i + j for j in a)
<generator object <genexpr> at 0x7f231e78c740>
➜ cpython git:(master) python3.10
Python 3.10.0a1+ (heads/master:b580ed1, Oct 19 2020, 15:52:12)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> i =2
>>> a = [1, 2, 3, 4]
>>> (b := i + j for j in a)
File "<stdin>", line 1
(b := i + j for j in a)
^
SyntaxError: invalid syntax
This is a regression introduced by the new parser.
Activity
lysnikolaou commentedon Nov 16, 2020
While a walrus is valid withing generator expressions in 3.8, it's not in 3.9 and onward.
This is a regression introduced by the new parser.
miss-islington commentedon Nov 16, 2020
New changeset cb3e5ed by Lysandros Nikolaou in branch 'master':
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319)
cb3e5ed
lysnikolaou commentedon Nov 16, 2020
New changeset 2b800ef by Lysandros Nikolaou in branch '3.9':
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319) (GH-23329)
2b800ef