classification
Title: Wrong error message for list/tuple followed by a colon
Type: behavior Stage: resolved
Components: Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lys.nikolaou Nosy List: brandtbucher, gvanrossum, lys.nikolaou, pablogsal
Priority: normal Keywords: patch

Created on 2020-06-25 22:36 by lys.nikolaou, last changed 2020-06-26 23:14 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21160 merged lys.nikolaou, 2020-06-25 22:41
PR 21172 merged lys.nikolaou, 2020-06-26 20:37
Messages (3)
msg372390 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-06-25 22:36
Brandt found this out while testing his implementation of the `match` statement. When a list or tuple are followed by a colon without an annotation, the old parser used to say "invalid syntax", while the new parser considers this an annotation and outputs something along the lines of "only single target (not tuple) can be annotated". For example:

➜  cpython git:(master) ./python.exe
Python 3.10.0a0 (heads/master:06a40d7359, Jun 26 2020, 01:33:34)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> (a, b):
  File "<stdin>", line 1
    (a, b):
    ^
SyntaxError: only single target (not tuple) can be annotated
>>> [a, b]:
  File "<stdin>", line 1
    [a, b]:
    ^
SyntaxError: only single target (not list) can be annotated
>>> a,:
  File "<stdin>", line 1
    a,:
    ^
SyntaxError: only single target (not tuple) can be annotated

The behavior of the old parser seems more logical.
msg372394 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-06-25 23:22
New changeset 4b85e60601489f9ee9dd2909e28d89a31566887c by Lysandros Nikolaou in branch 'master':
bpo-41119: Output correct error message for list/tuple followed by colon (GH-21160)
https://github.com/python/cpython/commit/4b85e60601489f9ee9dd2909e28d89a31566887c
msg372446 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-06-26 23:14
New changeset d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4 by Lysandros Nikolaou in branch '3.9':
[3.9] bpo-41119: Output correct error message for list/tuple followed by colon (GH-21160) (GH-21172)
https://github.com/python/cpython/commit/d01a3e76ee0519cba3ccdb5de47b25ec2ed7bee4
History
Date User Action Args
2020-06-26 23:14:19pablogsalsetmessages: + msg372446
2020-06-26 20:44:08lys.nikolaousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-26 20:37:36lys.nikolaousetpull_requests: + pull_request20330
2020-06-25 23:22:41pablogsalsetmessages: + msg372394
2020-06-25 22:41:02lys.nikolaousetkeywords: + patch
stage: patch review
pull_requests: + pull_request20320
2020-06-25 22:36:38lys.nikolaoucreate