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: Parse error when missing commas is inconsistent
Type: Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: AlexWaygood, Carl.Friedrich.Bolz, pablogsal
Priority: normal Keywords: patch

Created on 2021-11-05 12:44 by Carl.Friedrich.Bolz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29427 merged pablogsal, 2021-11-05 13:21
PR 29647 merged pablogsal, 2021-11-19 23:16
PR 29757 merged pablogsal, 2021-11-24 18:25
PR 29767 merged pablogsal, 2021-11-24 20:54
Messages (6)
msg405792 - (view) Author: Carl Friedrich Bolz-Tereick (Carl.Friedrich.Bolz) * Date: 2021-11-05 12:44
I found following inconsistency in the error message when there's a missing comma (it behaves that way both on main and 3.10).

Here's what happens with numbers, as expected:

Python 3.11.0a1+ (heads/main:32f55d1a5d, Nov  5 2021, 13:18:52) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 2 3 4
  File "<stdin>", line 1
    1 2 3 4
    ^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

But with names the error is further right in the lines:

>>> a b c d
  File "<stdin>", line 1
    a b c d
      ^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
>>> a b c d e f g
  File "<stdin>", line 1
    a b c d e f g
              ^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

That looks potentially quite confusing to me?

(I don't know if these nit-picky parsing issues are too annoying, if they are please tell me to stop filing them).
msg405794 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-05 13:08
>(I don't know if these nit-picky parsing issues are too annoying, if they are please tell me to stop filing them).

Don't worry, I think is great to discuss these cases. If there are too many, then maybe it will take a while to correct, but please, don't stop :)

> That looks potentially quite confusing to me?

I agree is unfortunate that is inconsistent, but unfortunately, this is going to be a bit of a pain because the way the expression rule is reached. I will try to see if we can easily fix this without having to restructure a bunch of the grammar
msg406625 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-19 23:12
New changeset 546cefcda75d7150b55c8bc1724bea35a1e12890 by Pablo Galindo Salgado in branch 'main':
bpo-45727: Make the syntax error for missing comma more consistent (GH-29427)
https://github.com/python/cpython/commit/546cefcda75d7150b55c8bc1724bea35a1e12890
msg406676 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-20 17:39
New changeset 511ee1c0fa4dedf32cc2b9f9fa13aa61e07bd165 by Pablo Galindo Salgado in branch '3.10':
[3.10] bpo-45727: Make the syntax error for missing comma more consistent (GH-29427) (GH-29647)
https://github.com/python/cpython/commit/511ee1c0fa4dedf32cc2b9f9fa13aa61e07bd165
msg406968 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-24 22:21
New changeset 24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1 by Pablo Galindo Salgado in branch 'main':
bpo-45727: Only trigger the 'did you forgot a comma' error suggestion if inside parentheses (GH-29757)
https://github.com/python/cpython/commit/24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1
msg406972 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-25 01:01
New changeset c72311d91787005713bb5daf4532a86e06496afd by Pablo Galindo Salgado in branch '3.10':
[3.10] bpo-45727: Only trigger the 'did you forgot a comma' error suggestion if inside parentheses. (GH-29767)
https://github.com/python/cpython/commit/c72311d91787005713bb5daf4532a86e06496afd
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89890
2021-11-25 01:01:50pablogsalsetmessages: + msg406972
2021-11-24 22:21:33pablogsalsetmessages: + msg406968
2021-11-24 20:54:26pablogsalsetpull_requests: + pull_request28004
2021-11-24 18:25:14pablogsalsetpull_requests: + pull_request27995
2021-11-20 18:08:07pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-11-20 17:39:20pablogsalsetmessages: + msg406676
2021-11-19 23:16:33pablogsalsetpull_requests: + pull_request27879
2021-11-19 23:12:04pablogsalsetmessages: + msg406625
2021-11-05 13:21:27pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27680
2021-11-05 13:08:56pablogsalsetmessages: + msg405794
2021-11-05 12:56:01AlexWaygoodsetnosy: + AlexWaygood
2021-11-05 12:44:09Carl.Friedrich.Bolzcreate