Skip to content
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

Closed
aroberge mannequin opened this issue Feb 3, 2021 · 10 comments
Closed

Incorrect SyntaxError message for missing comma (3.10.a5) #87287

aroberge mannequin opened this issue Feb 3, 2021 · 10 comments
Labels
3.10 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@aroberge
Copy link
Mannequin

aroberge mannequin commented Feb 3, 2021

BPO 43121
Nosy @aroberge, @pablogsal, @alexmojaki
PRs
  • bpo-43121: Fix incorrect SyntaxError message for missing comma #24436
  • 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:

    assignee = None
    closed_at = <Date 2021-02-03.23:29:42.593>
    created_at = <Date 2021-02-03.21:05:50.339>
    labels = ['type-bug', '3.10']
    title = 'Incorrect SyntaxError message for missing comma (3.10.a5)'
    updated_at = <Date 2021-05-04.21:20:14.241>
    user = 'https://github.com/aroberge'

    bugs.python.org fields:

    activity = <Date 2021-05-04.21:20:14.241>
    actor = 'alexmojaki'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-02-03.23:29:42.593>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-02-03.21:05:50.339>
    creator = 'aroberge'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43121
    keywords = ['patch']
    message_count = 10.0
    messages = ['386457', '386460', '386461', '386463', '386464', '386465', '386469', '386470', '386471', '392958']
    nosy_count = 3.0
    nosy_names = ['aroberge', 'pablogsal', 'alexmojaki']
    pr_nums = ['24436']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43121'
    versions = ['Python 3.10']

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Feb 3, 2021

    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?

    @aroberge aroberge mannequin added 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Feb 3, 2021
    @pablogsal
    Copy link
    Member

    Thanks Andre for the report. Will fix it soon

    @pablogsal
    Copy link
    Member

    Andre, could you check if this works in your test suite correctly?

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Feb 3, 2021

    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.)

    @pablogsal
    Copy link
    Member

    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?

    @pablogsal
    Copy link
    Member

    New changeset d4e6ed7 by Pablo Galindo in branch 'master':
    bpo-43121: Fix incorrect SyntaxError message for missing comma (GH-24436)
    d4e6ed7

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Feb 4, 2021

    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.

    @pablogsal
    Copy link
    Member

    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. :)

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Feb 4, 2021

    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

    @alexmojaki
    Copy link
    Mannequin

    alexmojaki mannequin commented May 4, 2021

    Pablo, check out aroberge/friendly#197, particularly the second bullet point which has a dataset of syntax errors.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant