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: Incorrect SyntaxError message for missing comma (3.10.a5)
Type: behavior Stage: resolved
Components: Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexmojaki, aroberge, pablogsal
Priority: normal Keywords: patch

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

Pull Requests
URL Status Linked Edit
PR 24436 merged pablogsal, 2021-02-03 22:33
Messages (10)
msg386457 - (view) Author: Andre Roberge (aroberge) * Date: 2021-02-03 21:05
A missing comma between list items results in an incorrect message.


Python 3.10.0a5 (tags/v3.10.0a5:b0478d7, Feb  3 2021, 01:44:54) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> a = [1, 2 3]
  File "<stdin>", line 1
    a = [1, 2 3]
         ^
SyntaxError: did you forget parentheses around the comprehension target?
msg386460 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-03 22:24
Thanks Andre for the report. Will fix it soon
msg386461 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-03 22:35
Andre, could you check if this works in your test suite correctly?
msg386463 - (view) Author: Andre Roberge (aroberge) * Date: 2021-02-03 22:42
Pablo: I have almost exactly the same 4 test cases that you added in the test suite, so it would pass my tests too. I would consider it to be resolved.

(For example: https://aroberge.github.io/friendly-traceback-docs/docs/html/syntax_tracebacks_en_3.9.html#missing-comma-in-a-set -- although I need to fix the suggestions I offer in my own code as they are currently wrong.)
msg386464 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-03 22:47
> Pablo: I have almost exactly the same 4 test cases that you added in the test suite, so it would pass my tests too. I would consider it to be resolved.

Fantastic. Also, for the future, could you indicate how could I run the test suite of friendly-traceback?
msg386465 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-03 23:29
New changeset d4e6ed7e5fb43320ea714d7436bc11667c624d43 by Pablo Galindo in branch 'master':
bpo-43121: Fix incorrect SyntaxError message for missing comma (GH-24436)
https://github.com/python/cpython/commit/d4e6ed7e5fb43320ea714d7436bc11667c624d43
msg386469 - (view) Author: Andre Roberge (aroberge) * Date: 2021-02-04 00:15
Pablo: to run the friendly-traceback test suite is simply a matter of typing "pytest" from the root directory of the repository (after installing the dependencies). However, it would not be helpful for the purpose of CPython development, as likely more failing tests would be due to Friendly-traceback itself.

As a first step, Friendly-traceback tries to make use of the information given by Python (for example, the new "expected ':'"); if it does not recognize the message, or if the message is "invalid syntax", it uses some heuristics to guess what might be the probable cause. 

Improvements to the messages given by CPython are likely going to initially result in failed tests for Friendly-traceback, whether the information provided by CPython is valid (most of the time) or not.

The test suite I use includes things that I imagine a beginner might write. For example, using "else if" instead of "elif".  With one of the newest additions of CPython ("expected ':'") which is accurate in most cases, this specific unit test would likely fail until I make the appropriate adjustement to Friendly-traceback.
msg386470 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-02-04 00:20
Thanks Andre for the thorough explanation!

The reason I was interested in running it myself is that as you are running on syntax errors, is a good corpus of things that fail with error messages, which is something that we have not been able to find as much as possible when trying new developments and proof of concepts. I am more interested in extracting the error cases and such so we can use them in future improvements. :)
msg386471 - (view) Author: Andre Roberge (aroberge) * Date: 2021-02-04 00:27
Pablo:
The tests are in https://github.com/aroberge/friendly-traceback/tree/master/tests/syntax

I plan to soon add at least two dozen more based on recent contributions.


The full results can be seen on the documentation site; for example https://aroberge.github.io/friendly-traceback-docs/docs/html/syntax_tracebacks_en_3.9.html

I track changes in error messages from CPython: https://aroberge.github.io/friendly-traceback-docs/docs/html/compare.html
msg392958 - (view) Author: Alex Hall (alexmojaki) Date: 2021-05-04 21:20
Pablo, check out https://github.com/aroberge/friendly/discussions/197, particularly the second bullet point which has a dataset of syntax errors.
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87287
2021-05-04 21:20:14alexmojakisetnosy: + alexmojaki
messages: + msg392958
2021-02-04 00:27:07arobergesetmessages: + msg386471
2021-02-04 00:20:23pablogsalsetmessages: + msg386470
2021-02-04 00:15:43arobergesetmessages: + msg386469
2021-02-03 23:29:42pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-02-03 23:29:33pablogsalsetmessages: + msg386465
2021-02-03 22:47:34pablogsalsetmessages: + msg386464
2021-02-03 22:42:49arobergesetmessages: + msg386463
2021-02-03 22:35:25pablogsalsetmessages: + msg386461
2021-02-03 22:33:17pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23244
2021-02-03 22:24:05pablogsalsetmessages: + msg386460
2021-02-03 21:13:22iritkatrielsetnosy: + pablogsal
2021-02-03 21:05:50arobergecreate