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.

Author aroberge
Recipients aroberge, lys.nikolaou, pablogsal
Date 2021-05-19.21:22:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621459324.97.0.279121411647.issue44181@roundup.psfhosted.org>
In-reply-to
Content
When forgetting a comma in writing a dict literal spanning multiple lines,
the "bad token" is wrongly idenfied with Python 3.10.0b1.

>>> a = {'a': 1
...      'b': 2
  File "<stdin>", line 1
    a = {'a': 1
              ^
SyntaxError: invalid syntax. Perhaps you forgot a comma?


Previously, this was shown:

>>> a = {'a': 1
...      'b': 2
  File "<stdin>", line 2
    'b': 2
    ^
SyntaxError: invalid syntax

However, I hasten to add that the new hint about a missing comma is spot on,
and likely to be extremely useful.

Note: this is based on my "intuition" built from previous version where the token identified by ^
was the first token that the Python parser was not able to make sense of.
Now that the parser highlight a range (if relevant tokens are on a single line),
it makes sense to include tokens preceding the "bad token".
However, when we have an error where such range
spans multiple lines, it can create "problems" such as that shown above.

Perhaps this is not worth attempting to fix and Python programmers like me will have to develop a "new intuition" in such cases (and "fix" friendly so that it can figure out the correct "bad token"
independently of cPython's information)
... and this bug report can be simply closed.
History
Date User Action Args
2021-05-19 21:22:05arobergesetrecipients: + aroberge, lys.nikolaou, pablogsal
2021-05-19 21:22:04arobergesetmessageid: <1621459324.97.0.279121411647.issue44181@roundup.psfhosted.org>
2021-05-19 21:22:04arobergelinkissue44181 messages
2021-05-19 21:22:04arobergecreate