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 lys.nikolaou
Recipients gvanrossum, lys.nikolaou, pablogsal
Date 2020-02-05.21:21:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580937682.24.0.516632817266.issue39564@roundup.psfhosted.org>
In-reply-to
Content
When concatenating f-strings, if there is an expression in any STRING node other than the first, col_offset of the parsed expression has a wrong value.

For example, parsing f"hello" f"{world}" outputs the following AST:

Module(
    body=[
        Expr(
            value=JoinedStr(
                values=[
                    Constant(
                        value="hello",
                        kind=None,
                        lineno=1,
                        col_offset=0,
                        end_lineno=1,
                        end_col_offset=19,
                    ),
                    FormattedValue(
                        value=Name(
                            id="world",
                            ctx=Load(),
                            lineno=1,
                            *col_offset=1,*
                            end_lineno=1,
                            *end_col_offset=6,*
                        ),
                        conversion=-1,
                        format_spec=None,
                        lineno=1,
                        col_offset=0,
                        end_lineno=1,
                        end_col_offset=19,
                    ),
                ],
                lineno=1,
                col_offset=0,
                end_lineno=1,
                end_col_offset=19,
            ),
            lineno=1,
            col_offset=0,
            end_lineno=1,
            end_col_offset=19,
        )
    ],
    type_ignores=[],
)

Here, col_offset and end_col_offset are wrong in the parsed NAME 'world'.
History
Date User Action Args
2020-02-05 21:21:22lys.nikolaousetrecipients: + lys.nikolaou, gvanrossum, pablogsal
2020-02-05 21:21:22lys.nikolaousetmessageid: <1580937682.24.0.516632817266.issue39564@roundup.psfhosted.org>
2020-02-05 21:21:22lys.nikolaoulinkissue39564 messages
2020-02-05 21:21:21lys.nikolaoucreate