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 line reported in syntax error #86375

Closed
gkuhn mannequin opened this issue Oct 30, 2020 · 5 comments
Closed

Incorrect line reported in syntax error #86375

gkuhn mannequin opened this issue Oct 30, 2020 · 5 comments
Labels
3.10 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@gkuhn
Copy link
Mannequin

gkuhn mannequin commented Oct 30, 2020

BPO 42209
Nosy @terryjreedy, @ericvsmith
Superseder
  • bpo-46237: Incorrect line reported in syntax error
  • Files
  • test.py: script showing a syntax error with an incorrect line nr
  • 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 2020-10-31.00:25:11.236>
    created_at = <Date 2020-10-30.15:29:34.699>
    labels = ['type-bug', '3.10']
    title = 'Incorrect line reported in syntax error'
    updated_at = <Date 2022-01-07.19:07:03.167>
    user = 'https://bugs.python.org/gkuhn'

    bugs.python.org fields:

    activity = <Date 2022-01-07.19:07:03.167>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-31.00:25:11.236>
    closer = 'eric.smith'
    components = []
    creation = <Date 2020-10-30.15:29:34.699>
    creator = 'gkuhn'
    dependencies = []
    files = ['50491']
    hgrepos = []
    issue_num = 42209
    keywords = []
    message_count = 5.0
    messages = ['379977', '379981', '379990', '408591', '410006']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'eric.smith', 'gkuhn', 'arian-f']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = '46237'
    type = 'behavior'
    url = 'https://bugs.python.org/issue42209'
    versions = ['Python 3.10']

    @gkuhn
    Copy link
    Mannequin Author

    gkuhn mannequin commented Oct 30, 2020

    Attempting to parse the following python code results in a fairly unhelpful syntax error along with an incorrect line number being reported:

    #a dodgy f-string
    
        def dodgy(**kwargs):
            print(f"{**kwargs}")

    The result:

    File "<fstring>", line 1
    (**kwargs)
    ^
    SyntaxError: invalid syntax

    $ python -VV
    Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]

    @gkuhn gkuhn mannequin added 3.8 only security fixes type-bug An unexpected behavior, bug, or error labels Oct 30, 2020
    @ericvsmith
    Copy link
    Member

    The line number has been fixed in python 3.9:

    File "...\foo.py", line 5
    (**kwargs)
    ^
    SyntaxError: f-string: invalid syntax

    The error message should improve when we move parsing of f-strings into the parser. I doubt we'd put in the effort to do anything before then.

    @gkuhn
    Copy link
    Mannequin Author

    gkuhn mannequin commented Oct 30, 2020

    Ah, that makes sense, thank you for the info.

    The line number is probably the most important piece of information here anyway.

    It sounds like the syntax error string is already planned and as such this is probably a duplicate.

    Please close if this is the case.

    Cheers

    @arian-f
    Copy link
    Mannequin

    arian-f mannequin commented Dec 15, 2021

    There are still variations of this issue in python 3.10 - the line nr is correct - in script attached it's line 2 (the attached script is otherwise the same):

    f'{ 1_a }'
    

    resulting in:

    File "test.py", line 1
    ( 1_a )
    ^
    SyntaxError: invalid decimal literal

    or is this a different but similar bug? Can this bug be reopened or should I file a new bug?

    python -VV
    Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]

    @arian-f arian-f mannequin added 3.10 only security fixes and removed 3.8 only security fixes labels Dec 15, 2021
    @terryjreedy
    Copy link
    Member

    Arian-f's new issue is bpo-46237.

    @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

    2 participants