You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FormattedValue expressions have wrong lineno and col_offset information #74650
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).
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.
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
Activity
ambv commentedon 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.
rhettinger commentedon May 25, 2017
Thanks for adding so many tests.
serhiy-storchaka commentedon May 31, 2017
I have concerns about following cases.
f'{x} {x}'
or
f'''
{x}
{x}
'''
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 commentedon Sep 5, 2017
See also bpo-31140: I'm not sure if that case is covered by this issue.
ericvsmith commentedon Sep 7, 2017
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 commentedon Sep 7, 2017
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 commentedon Oct 2, 2017
Is there more to do on this issue or can it be closed now?
ericvsmith commentedon Oct 4, 2017
I think it's fixed. Closing.
ambv commentedon 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 commentedon Apr 23, 2019
New changeset 8a9a6b4 by Victor Stinner in branch '3.7':
[3.7] bpo-9566: Fix compiler warnings on Windows (GH-12920)
8a9a6b4