Navigation Menu

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 bad token identified in 3.10.1 #90162

Closed
aroberge mannequin opened this issue Dec 7, 2021 · 5 comments
Closed

Incorrect bad token identified in 3.10.1 #90162

aroberge mannequin opened this issue Dec 7, 2021 · 5 comments
Labels
3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@aroberge
Copy link
Mannequin

aroberge mannequin commented Dec 7, 2021

BPO 46004
Nosy @aroberge, @lysnikolaou, @pablogsal
PRs
  • bpo-46004: Fix error location for loops with invalid targets #29959
  • bpo-46004: Fix error location for loops with invalid targets #29959
  • [3.10] bpo-46004: Fix error location for loops with invalid targets (GH-29959) #29961
  • 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-12-07.15:23:40.135>
    created_at = <Date 2021-12-07.06:11:16.742>
    labels = ['interpreter-core', '3.10']
    title = 'Incorrect bad token identified in 3.10.1'
    updated_at = <Date 2021-12-07.15:24:54.554>
    user = 'https://github.com/aroberge'

    bugs.python.org fields:

    activity = <Date 2021-12-07.15:24:54.554>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-07.15:23:40.135>
    closer = 'pablogsal'
    components = ['Parser']
    creation = <Date 2021-12-07.06:11:16.742>
    creator = 'aroberge'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46004
    keywords = ['patch', 'patch']
    message_count = 5.0
    messages = ['407894', '407895', '407933', '407941', '407942']
    nosy_count = 3.0
    nosy_names = ['aroberge', 'lys.nikolaou', 'pablogsal']
    pr_nums = ['29959', '29959', '29961']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46004'
    versions = ['Python 3.10']

    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Dec 7, 2021

    In Python 3.10.1, a change occurred compared with 3.10.0 so that an incorrect token is flagged for a SyntaxError. Also, in 3.11.0a2, the suggestion made about having forgotten a comma is incorrect.

    Python 3.10.1
    for x range(4):
    ^
    SyntaxError: invalid syntax

    (I no longer have 3.10.0 available but I know from my tests that it was identifying correctly the wrong token.)

    Python 3.11.0a2
    for x range(4):
    ^^^^^^^^^^
    SyntaxError: invalid syntax. Perhaps you forgot a comma?

    Python 3.9.5
    for x range(4):
    ^
    SyntaxError: invalid syntax

    Python 3.8.10
    for x range(4):
    ^
    SyntaxError: invalid syntax

    Python 3.7.8
    for x range(4):
    ^
    SyntaxError: invalid syntax

    Python 3.6.8
    for x range(4):
    ^
    SyntaxError: invalid syntax

    @aroberge aroberge mannequin added 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Dec 7, 2021
    @aroberge
    Copy link
    Mannequin Author

    aroberge mannequin commented Dec 7, 2021

    From (https://friendly-traceback.github.io/docs/syntax_tracebacks_en_3.10.html#for-loop-missing-in-operator), this is what was shown for Python 3.10.0

        for x range(4):
            ^^^^^^^^^^
    SyntaxError: invalid syntax. Perhaps you forgot a comma?

    Same as Python 3.11.0a2.

    @pablogsal
    Copy link
    Member

    New changeset 1c7a1c3 by Pablo Galindo Salgado in branch 'main':
    bpo-46004: Fix error location for loops with invalid targets (GH-29959)
    1c7a1c3

    @pablogsal
    Copy link
    Member

    New changeset c521412 by Pablo Galindo Salgado in branch '3.10':
    [3.10] bpo-46004: Fix error location for loops with invalid targets (GH-29959). (GH-29961)
    c521412

    @pablogsal
    Copy link
    Member

    From (https://friendly-traceback.github.io/docs/syntax_tracebacks_en_3.10.html#for-loop-missing-in-operator), this is what was shown for Python 3.10.0

    Yeah, we are not showing that anymore as we only trigger the error when it happens inside collections to avoid many of the false positives we were seeing.

    This PR fixes the problem to point to the correct token, but still show "syntax error"

    @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 interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant