Incorrect line number of wrong symbol name inside f-strings
Bug #1666811 reported by
Lele Gaifax
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
All errors related to undefined symbols used within f-strings are reported with an incorrect line number of "1".
The following snippet
print('Foo')
print(f'{a}')
reports
p.py:1: undefined name 'a'
whereas the error appears on line 2.
Changed in pyflakes: | |
status: | New → Confirmed |
To post a comment you must log in.
This is not a problem in PyFlakes but in the formatted literals implementation in the core of CPython itself. The AST child Name node for the formatting variables reports 1 as both line and column as the nodes are generated by PyParser_ ASTFromString "automagically" in fstring_find_expr (Python/ pythoinrun. c and Python/ast.c respectively).
I don't see how this should/could be fixed by PyFlakes