Closed as not planned
Description
Bug report
The elements of f-string ast contain the offsets of the f-string, not their own.
import ast
# 10 20 30
#123456789012345678901234567890
source = """\
f"aaa{1}bbb{2}ccc{3}"
"""
#123456789012345678901234567890
# 10 20 30
r = ast.parse(source)
for v in r.body[0].value.values:
print(v.col_offset, v.end_col_offset, source[v.col_offset:v.end_col_offset])
Expected output:
2 5 aaa
6 7 1
8 10 bbb
12 13 2
14 17 ccc
18 19 3
Actual output:
0 21 f"aaa{1}bbb{2}ccc{3}"
0 21 f"aaa{1}bbb{2}ccc{3}"
0 21 f"aaa{1}bbb{2}ccc{3}"
0 21 f"aaa{1}bbb{2}ccc{3}"
0 21 f"aaa{1}bbb{2}ccc{3}"
0 21 f"aaa{1}bbb{2}ccc{3}"
Your environment
- CPython versions tested on:
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
- CPython versions tested on:
Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0] on linux
- Operating system and architecture:
Ubuntu 22.04.1 LTS