-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect SyntaxError message for missing comma (3.10.a5) #87287
Comments
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 >>> a = [1, 2 3]
File "<stdin>", line 1
a = [1, 2 3]
^
SyntaxError: did you forget parentheses around the comprehension target? |
Thanks Andre for the report. Will fix it soon |
Andre, could you check if this works in your test suite correctly? |
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.) |
Fantastic. Also, for the future, could you indicate how could I run the test suite of friendly-traceback? |
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. |
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. :) |
Pablo: 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 |
Pablo, check out aroberge/friendly#197, particularly the second bullet point which has a dataset of syntax errors. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: