New submission from Lysandros Nikolaou <lisandros...@gmail.com>:
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'. ---------- components: Interpreter Core messages: 361456 nosy: gvanrossum, lys.nikolaou, pablogsal priority: normal severity: normal status: open title: Parsed expression has wrong line/col info when concatenating f-strings versions: Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39564> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com