Skip to content

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

Closed

Description

@bgailer
mannequin
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']

    Activity

    1. bgailer commented on Aug 8, 2018

      bgailermannequin
      MannequinAuthor

      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
    2. MojoVampire commented on Aug 9, 2018

      MojoVampiremannequin
      Mannequin

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

    3. ericvsmith commented on Aug 9, 2018

      @ericvsmith
      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.

    4. self-assigned this
      on Aug 9, 2018
    5. ericvsmith commented on Sep 24, 2018

      @ericvsmith
      Member

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

    6. serhiy-storchaka commented on Sep 24, 2018

      @serhiy-storchaka
      Member

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

    7. ericvsmith commented on Sep 24, 2018

      @ericvsmith
      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.

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.7 (EOL)end of life3.8 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions