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.

Author asmeurer
Recipients asmeurer
Date 2020-03-04.18:41:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583347311.91.0.313226476752.issue39854@roundup.psfhosted.org>
In-reply-to
Content
This is tested in CPython master. The issue also occurs in older versions of Python. 

>>> ast.dump(ast.parse('f"{x}"'))
"Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1, format_spec=None)]))], type_ignores=[])"
>>> ast.dump(ast.parse('f"{x!r}"'))
"Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=114, format_spec=None)]))], type_ignores=[])"
>>> ast.parse('f"{x}"').body[0].value.values[0].value.col_offset
3
>>> ast.parse('f"{x!r}"').body[0].value.values[0].value.col_offset
1

The col_offset for the variable x should be 3 in both instances.
History
Date User Action Args
2020-03-04 18:41:51asmeurersetrecipients: + asmeurer
2020-03-04 18:41:51asmeurersetmessageid: <1583347311.91.0.313226476752.issue39854@roundup.psfhosted.org>
2020-03-04 18:41:51asmeurerlinkissue39854 messages
2020-03-04 18:41:51asmeurercreate