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: Improve syntax errors for invalid dictionary literals
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pablogsal
Priority: normal Keywords: patch

Created on 2021-04-13 02:05 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25378 merged pablogsal, 2021-04-13 02:06
PR 25427 merged pablogsal, 2021-04-15 23:05
Messages (3)
msg390917 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-13 02:05
Currently the error for invalid dict literals is generic:

>>> {1:2, 3:}
  File "<stdin>", line 1
    {1:2, 3:}
            ^
SyntaxError: invalid syntax
>>> {1:2, 3}
  File "<stdin>", line 1
    {1:2, 3}
           ^
SyntaxError: invalid syntax

We can have better errors for these cases, which can help with big dict literals:

>>> {1:2, 3}
  File "<stdin>", line 1
    {1:2, 3}
           ^
SyntaxError: ':' expected after dictionary key
>>> {1:2, 3:}
  File "<stdin>", line 1
    {1:2, 3:}
           ^
SyntaxError: expression expected after dictionary key and ':'
msg391135 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-15 13:06
New changeset da7435017430671f86075449ff7bde96fd7700a5 by Pablo Galindo in branch 'master':
bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)
https://github.com/python/cpython/commit/da7435017430671f86075449ff7bde96fd7700a5
msg391155 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-15 23:45
New changeset b5b98bd8f8c72a9068cf149dbc162c8c95d30057 by Pablo Galindo in branch 'master':
bpo-43823: Fix location of one of the errors for invalid dictionary literals (GH-25427)
https://github.com/python/cpython/commit/b5b98bd8f8c72a9068cf149dbc162c8c95d30057
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 87989
2021-04-15 23:45:51pablogsalsetmessages: + msg391155
2021-04-15 23:05:36pablogsalsetpull_requests: + pull_request24160
2021-04-15 13:07:07pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-04-15 13:06:46pablogsalsetmessages: + msg391135
2021-04-13 02:06:45pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24110
2021-04-13 02:05:47pablogsalcreate