dscorbett · GitHub

Bug report

Bug description:

When a t-string is used as an index, the SyntaxWarning calls it a str. The warning reports the correct type for other types of invalid expression in that context. The TypeError also reports the correct type.

>>> [][t""]
<python-input-0>:1: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    [][t""]
    ~~^^^^^
TypeError: list indices must be integers or slices, not string.templatelib.Template

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Read the original on github.com ↗