Skip to content

gh-138372: Fix SyntaxWarning for erroneous t-string subscription#138375

Merged
pablogsal merged 2 commits into
python:mainfrom
brianschubert:gh-138372-syntaxwarning-tempalte
Sep 2, 2025
Merged

gh-138372: Fix SyntaxWarning for erroneous t-string subscription#138375
pablogsal merged 2 commits into
python:mainfrom
brianschubert:gh-138372-syntaxwarning-tempalte

Conversation

@brianschubert

@brianschubert brianschubert commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Demonstration:

>>> [][t""]
<python-input-2>:1: SyntaxWarning: list indices must be integers or slices, not string.templatelib.Template; perhaps you missed a comma?
...

>>> t""[0]
<python-input-3>:1: SyntaxWarning: 'string.templatelib.Template' object is not subscriptable; perhaps you missed a comma?
...

>>> t""()
<python-input-4>:1: SyntaxWarning: 'string.templatelib.Template' object is not callable; perhaps you missed a comma?
...

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well! Thanks @brianschubert!

@pablogsal pablogsal merged commit 5493b46 into python:main Sep 2, 2025
53 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @brianschubert for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 2, 2025
pythonGH-138375)

(cherry picked from commit 5493b46)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
@bedevere-app

bedevere-app Bot commented Sep 2, 2025

Copy link
Copy Markdown

GH-138392 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 2, 2025
pablogsal pushed a commit that referenced this pull request Sep 2, 2025
…on (GH-138375) (#138392)

gh-138372: Fix SyntaxWarning for erroneous t-string subscription (GH-138375)
(cherry picked from commit 5493b46)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…cription (pythonGH-138375) (python#138392)

pythongh-138372: Fix SyntaxWarning for erroneous t-string subscription (pythonGH-138375)
(cherry picked from commit 5493b46)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants