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.

Title: Improve error message in the parser when using un-parenthesised tuples in comprehensions
Type: Stage: resolved
Components: Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, lys.nikolaou, pablogsal
Priority: normal Keywords: patch

Created on 2021-01-24 18:00 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24314 merged pablogsal, 2021-01-24 18:02
Messages (3)
msg385586 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-01-24 18:00
I have seen this confusion many users over the years. Instead of showing:

❯ python -c '[x,z for x,y in something]'
  File "<string>", line 1
    [x,z for x,y in something]
SyntaxError: invalid syntax

We can show:

❯ ./python -c '[x,z for x,y in something]'
  File "<string>", line 1
    [x,z for x,y in something]
SyntaxError: did you forgot parentheses around the comprehension target?
msg385655 - (view) Author: Andre Roberge (aroberge) * Date: 2021-01-25 19:49
Such a change would be very useful and appreciated by other users as reported on and asked about on StackOverflow
msg386045 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-01-31 22:52
New changeset 835f14ff8eec10b3d96f821a1eb46a986e00c690 by Pablo Galindo in branch 'master':
bpo-43017: Improve error message for unparenthesised tuples in comprehensions (GH24314)
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87183
2021-01-31 22:53:06pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-01-31 22:52:59pablogsalsetmessages: + msg386045
2021-01-25 19:49:33arobergesetnosy: + aroberge
messages: + msg385655
2021-01-24 18:02:34pablogsalsetnosy: + lys.nikolaou
2021-01-24 18:02:26pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23133
2021-01-24 18:00:46pablogsalcreate