This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unparenthesized walrus is not allowed in genexps
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, lys.nikolaou, miss-islington, pablogsal, terry.reedy
Priority: normal Keywords: 3.9regression, patch

Created on 2020-11-16 17:43 by lys.nikolaou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23319 merged lys.nikolaou, 2020-11-16 17:54
PR 23329 merged lys.nikolaou, 2020-11-16 23:14
Messages (3)
msg381133 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-11-16 17:43
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.
msg381178 - (view) Author: miss-islington (miss-islington) Date: 2020-11-16 23:08
New changeset cb3e5ed0716114393696ec7201e51fe0595eab4f by Lysandros Nikolaou in branch 'master':
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319)
https://github.com/python/cpython/commit/cb3e5ed0716114393696ec7201e51fe0595eab4f
msg381185 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-11-16 23:39
New changeset 2b800ef809eefbc96a536e4b43a8285f2353f64d by Lysandros Nikolaou in branch '3.9':
bpo-42374: Allow unparenthesized walrus in genexps (GH-23319) (GH-23329)
https://github.com/python/cpython/commit/2b800ef809eefbc96a536e4b43a8285f2353f64d
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86540
2020-11-16 23:39:39lys.nikolaousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-11-16 23:39:06lys.nikolaousetmessages: + msg381185
2020-11-16 23:14:58lys.nikolaousetpull_requests: + pull_request22217
2020-11-16 23:08:38miss-islingtonsetnosy: + miss-islington
messages: + msg381178
2020-11-16 17:54:33lys.nikolaousetkeywords: + patch
stage: patch review
pull_requests: + pull_request22210
2020-11-16 17:43:28lys.nikolaoucreate