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

problem with traceback for syntax error in f-string #78545

Closed
bgailer mannequin opened this issue Aug 8, 2018 · 6 comments
Closed

problem with traceback for syntax error in f-string #78545

bgailer mannequin opened this issue Aug 8, 2018 · 6 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@bgailer
Copy link
Mannequin

bgailer mannequin commented Aug 8, 2018

BPO 34364
Nosy @ods, @ericvsmith, @serhiy-storchaka, @MojoVampire
PRs
  • bpo-16806: Fix lineno and col_offset for multi-line string tokens. #10021
  • 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 = 'https://github.com/ericvsmith'
    closed_at = <Date 2020-11-19.12:39:34.592>
    created_at = <Date 2018-08-08.20:42:15.759>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7']
    title = 'problem with traceback for syntax error in f-string'
    updated_at = <Date 2020-11-19.12:39:34.592>
    user = 'https://bugs.python.org/bgailer'

    bugs.python.org fields:

    activity = <Date 2020-11-19.12:39:34.592>
    actor = 'iritkatriel'
    assignee = 'eric.smith'
    closed = True
    closed_date = <Date 2020-11-19.12:39:34.592>
    closer = 'iritkatriel'
    components = ['Interpreter Core']
    creation = <Date 2018-08-08.20:42:15.759>
    creator = 'bgailer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34364
    keywords = ['patch']
    message_count = 6.0
    messages = ['323301', '323309', '323311', '326264', '326268', '326269']
    nosy_count = 5.0
    nosy_names = ['ods', 'eric.smith', 'bgailer', 'serhiy.storchaka', 'josh.r']
    pr_nums = ['10021']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34364'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @bgailer
    Copy link
    Mannequin Author

    bgailer mannequin commented Aug 8, 2018

    Inconsistent tracebacks. Note that the traceback for bug.py does not
    reference the
    module file and line number.

    # bug.py
    def f():
       f'''
       {d e}'''
    a=b
    
    import bug
    Traceback (most recent call last):
       File "<fstring>", line 1
         (d e)
            ^
    SyntaxError: invalid syntax

    # bug2.py
    def f():
       f'''
       {de}'''
    a=b
    
    import bug2
    bug2.f()
    Traceback (most recent call last):
       File "C:\python\bug2.py", line 5, in <module>
         a=b
    NameError: name 'b' is not defined

    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented Aug 9, 2018

    So the bug is that the line number and module are incorrect for the f-string, right? Nothing else?

    @ericvsmith
    Copy link
    Member

    I think this is a duplicate, but I can't find the exact issue. I don't think it's exactly the same as bpo-29051.

    @ericvsmith ericvsmith added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.7 (EOL) end of life 3.8 only security fixes labels Aug 9, 2018
    @ericvsmith ericvsmith self-assigned this Aug 9, 2018
    @ericvsmith ericvsmith added the type-bug An unexpected behavior, bug, or error label Aug 9, 2018
    @ericvsmith
    Copy link
    Member

    I worked on this at the core sprint, and I have a patch almost ready.

    @serhiy-storchaka
    Copy link
    Member

    Great! I was going to take it. Will be glad to make a review.

    @ericvsmith
    Copy link
    Member

    It's more elaborate than I'd like, but I think it's the right way to solve it: I'm passing in the starting line and column number to the parser machinery.

    @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.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants