This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: FormattedValue expressions have wrong lineno and col_offset information
Type: behavior Stage: resolved
Components: Versions: Python 3.7, Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lukasz.langa Nosy List: Anthony Sottile, eric.smith, lukasz.langa, ned.deily, rhettinger, serhiy.storchaka, vstinner
Priority: normal Keywords: 3.6regression

Created on 2017-05-24 22:53 by lukasz.langa, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1800 merged lukasz.langa, 2017-05-24 22:57
PR 3409 merged python-dev, 2017-09-07 00:28
PR 6593 merged vstinner, 2018-04-25 12:48
PR 12920 merged vstinner, 2019-04-23 08:09
PR 10021 Anthony Sottile, 2020-04-01 23:22
Messages (10)
msg294408 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2017-05-24 22:53
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.
msg294423 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-05-25 01:34
Thanks for adding so many tests.
msg294866 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-31 18:58
I have concerns about following cases.

* f-string containing multiple equivalent subexpressions:

f'{x} {x}'



* f-string containing escaped newlines:


The tests look slightly verbose and fragile to me. If once the parser will produce more efficient tree (see issue26415), 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.
msg301368 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-09-05 20:37
See also issue 31140: I'm not sure if that case is covered by this issue.
msg301551 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-09-07 00:28
New changeset e7c566caf177afe43b57f0b2723e723d880368e8 by ericvsmith (Łukasz Langa) in branch 'master':
bpo-30465: Fix lineno and col_offset in fstring AST nodes (#1800)
msg301563 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-09-07 02:43
New changeset aa1afc72c1ee1f090e6302198d9a0295f1ce1c05 by ericvsmith (Miss Islington (bot)) in branch '3.6':
bpo-30465: Fix lineno and col_offset in fstring AST nodes (GH-1800) (gh-3409)
msg303571 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-10-02 23:58
Is there more to do on this issue or can it be closed now?
msg303680 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-10-04 12:08
I think it's fixed. Closing.
msg315971 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2018-04-30 21:51
New changeset fb7e7992beec7f76cc2db77ab6ce1e86446bfccf by Łukasz Langa (Victor Stinner) in branch 'master':
bpo-30465: Fix C downcast warning on Windows in ast.c (#6593)
msg340699 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-23 08:26
New changeset 8a9a6b443c57e47e9d10ed7775479aada4dac719 by Victor Stinner in branch '3.7':
[3.7] bpo-9566: Fix compiler warnings on Windows (GH-12920)
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74650
2020-04-01 23:22:36Anthony Sottilesetnosy: + Anthony Sottile

pull_requests: + pull_request18644
2019-04-23 08:26:14vstinnersetnosy: + vstinner
messages: + msg340699
2019-04-23 08:09:08vstinnersetpull_requests: + pull_request12847
2018-04-30 21:51:05lukasz.langasetmessages: + msg315971
2018-04-25 12:48:04vstinnersetpull_requests: + pull_request6291
2017-10-04 12:08:59eric.smithsetstatus: open -> closed
resolution: fixed
messages: + msg303680

stage: patch review -> resolved
2017-10-02 23:58:59ned.deilysetnosy: + ned.deily
messages: + msg303571
2017-09-07 02:43:06eric.smithsetmessages: + msg301563
2017-09-07 00:28:08python-devsetpull_requests: + pull_request3410
2017-09-07 00:28:00eric.smithsetmessages: + msg301551
2017-09-05 20:37:20eric.smithsetmessages: + msg301368
2017-06-15 17:14:38serhiy.storchakasetmessages: - msg296115
2017-06-15 17:14:26serhiy.storchakasetmessages: - msg296114
2017-06-15 17:01:02serhiy.storchakasetmessages: + msg296115
2017-06-15 16:58:43serhiy.storchakasetmessages: + msg296114
2017-05-31 18:58:39serhiy.storchakasetnosy: + eric.smith, serhiy.storchaka
messages: + msg294866
2017-05-25 01:34:16rhettingersetnosy: + rhettinger
messages: + msg294423
2017-05-24 22:57:05lukasz.langasetpull_requests: + pull_request1883
2017-05-24 22:53:37lukasz.langacreate