Skip to content

[3.14] gh-160491: Fix location of invalid escapes in f-strings and t-strings (GH-160493) - #160531

Merged
lysnikolaou merged 1 commit into
python:3.14from
miss-islington:backport-2258026-3.14
Oct 23, 2026
Merged

lysnikolaou merged 1 commit into
python:3.14from
miss-islington:backport-2258026-3.14

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Literal parts of f-strings and t-strings are decoded only after the
whole string has been parsed, so a decode error took the location of
the last token. The resulting SyntaxError pointed at the closing quote,
and for multi-line strings it could be on the wrong line.

Raise the error at the literal part being decoded instead.
(cherry picked from commit 2258026)

Co-authored-by: Lysandros Nikolaou lisandrosnik@gmail.com

…trings (pythonGH-160493)

Literal parts of f-strings and t-strings are decoded only after the
whole string has been parsed, so a decode error took the location of
the last token. The resulting SyntaxError pointed at the closing quote,
and for multi-line strings it could be on the wrong line.

Raise the error at the literal part being decoded instead.
(cherry picked from commit 2258026)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
@lysnikolaou
lysnikolaou merged commit dfbde8c into python:3.14 Oct 23, 2026
91 of 92 checks passed
@miss-islington
miss-islington deleted the backport-2258026-3.14 branch October 23, 2026 23:33
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.

2 participants