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

FormattedValue expressions have wrong lineno and col_offset information #74650

Closed
ambv opened this issue May 24, 2017 · 10 comments
Closed

FormattedValue expressions have wrong lineno and col_offset information #74650

ambv opened this issue May 24, 2017 · 10 comments
Assignees
Labels
3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error

Comments

@ambv
Copy link
Contributor

ambv commented May 24, 2017

BPO 30465
Nosy @rhettinger, @vstinner, @ericvsmith, @ned-deily, @ambv, @serhiy-storchaka, @asottile
PRs
  • bpo-30465: Fix lineno and col_offset in fstring AST nodes #1800
  • [3.6] bpo-30465: Fix lineno and col_offset in fstring AST nodes (GH-1800) #3409
  • bpo-30465: Fix C downcast warning on Windows in ast.c #6593
  • [3.7] bpo-9566: Fix compiler warnings on Windows #12920
  • 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/ambv'
    closed_at = <Date 2017-10-04.12:08:59.860>
    created_at = <Date 2017-05-24.22:53:37.508>
    labels = ['type-bug', '3.7']
    title = 'FormattedValue expressions have wrong lineno and col_offset information'
    updated_at = <Date 2020-04-01.23:22:36.159>
    user = 'https://github.com/ambv'

    bugs.python.org fields:

    activity = <Date 2020-04-01.23:22:36.159>
    actor = 'Anthony Sottile'
    assignee = 'lukasz.langa'
    closed = True
    closed_date = <Date 2017-10-04.12:08:59.860>
    closer = 'eric.smith'
    components = []
    creation = <Date 2017-05-24.22:53:37.508>
    creator = 'lukasz.langa'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30465
    keywords = ['3.6regression']
    message_count = 10.0
    messages = ['294408', '294423', '294866', '301368', '301551', '301563', '303571', '303680', '315971', '340699']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'vstinner', 'eric.smith', 'ned.deily', 'lukasz.langa', 'serhiy.storchaka', 'Anthony Sottile']
    pr_nums = ['1800', '3409', '6593', '12920', '10021']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30465'
    versions = ['Python 3.6', 'Python 3.7']

    @ambv
    Copy link
    Contributor Author

    ambv commented May 24, 2017

    f-strings are computed in a separate compiler step. This makes their lineno and col_offset information wrong. This is problematic for flake8 which reports problems inside f-strings on the wrong line (typically the first one).

    Attached patch fixes the issue.

    @ambv ambv added the 3.7 (EOL) end of life label May 24, 2017
    @ambv ambv self-assigned this May 24, 2017
    @ambv ambv added the type-bug An unexpected behavior, bug, or error label May 24, 2017
    @rhettinger
    Copy link
    Contributor

    Thanks for adding so many tests.

    @serhiy-storchaka
    Copy link
    Member

    I have concerns about following cases.

    • f-string containing multiple equivalent subexpressions:

    f'{x} {x}'

    or

    f'''
    {x}
    {x}
    '''

    • f-string containing escaped newlines:

    f'''\
    \
    {x}\
    \
    '''

    The tests look slightly verbose and fragile to me. If once the parser will produce more efficient tree (see bpo-26415), the tests may fail. Needed more tests (for cases mentioned above), and adding them will add more verbose code. Maybe just find the child (or several children) of specific type and check lineno and col_offset only for it and few its children? If this will make the tests simpler. But if tests can't be made simpler, we should live with this.

    @ericvsmith
    Copy link
    Member

    See also bpo-31140: I'm not sure if that case is covered by this issue.

    @ericvsmith
    Copy link
    Member

    New changeset e7c566c by ericvsmith (Łukasz Langa) in branch 'master':
    bpo-30465: Fix lineno and col_offset in fstring AST nodes (bpo-1800)
    e7c566c

    @ericvsmith
    Copy link
    Member

    New changeset aa1afc7 by ericvsmith (Miss Islington (bot)) in branch '3.6':
    bpo-30465: Fix lineno and col_offset in fstring AST nodes (GH-1800) (gh-3409)
    aa1afc7

    @ned-deily
    Copy link
    Member

    Is there more to do on this issue or can it be closed now?

    @ericvsmith
    Copy link
    Member

    I think it's fixed. Closing.

    @ambv
    Copy link
    Contributor Author

    ambv commented Apr 30, 2018

    New changeset fb7e799 by Łukasz Langa (Victor Stinner) in branch 'master':
    bpo-30465: Fix C downcast warning on Windows in ast.c (bpo-6593)
    fb7e799

    @vstinner
    Copy link
    Member

    New changeset 8a9a6b4 by Victor Stinner in branch '3.7':
    [3.7] bpo-9566: Fix compiler warnings on Windows (GH-12920)
    8a9a6b4

    @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 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants