Skip to content

[3.15] gh-155525: Fix quadratic f-string tokenization (GH-156756) - #157828

Merged
pablogsal merged 3 commits into
python:3.15from
miss-islington:backport-c1df684-3.15
Sep 19, 2026
Merged

pablogsal merged 3 commits into
python:3.15from
miss-islington:backport-c1df684-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Backport gh-156756 to Python 3.15. Retain replacement expressions in the tokenizer buffer instead of repeatedly copying the remaining source. Preserve the expression pointers when the buffer grows, and keep the interactive buffer while a formatted string is open.

Main already received the implementation through gh-156484, so the automatic cherry-pick only brought over tests. This backport also adapts the original fix to the release tokenizer and adds coverage for multiline interactive expressions, which otherwise abort in a debug build.

The targeted parser and command-line tests pass in a debug build, including the CPU-resource tests.

(cherry picked from commit c1df684)

pablogsal and others added 2 commits September 19, 2026 22:37
Adapt the original expression-span fix to the release tokenizer and retain interactive buffers while a formatted string is open.

Co-authored-by: gwosti <322952417+gwosti@users.noreply.github.com>
…thonGH-156756)

* pythongh-155525: Avoid quadratic f-string tokenization

* fixup! pythongh-155525: Avoid quadratic f-string tokenization

---------
(cherry picked from commit c1df6843d36233ec1da71a1d5f9b74dd6ebc9b97)

Co-authored-by: gwosti <322952417+gwosti@users.noreply.github.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
@pablogsal
pablogsal self-requested a review as a code owner September 19, 2026 22:06
@pablogsal pablogsal changed the title [3.15] gh-155525: Cover quadratic f-string tokenization regression (GH-156756) [3.15] gh-155525: Fix quadratic f-string tokenization (GH-156756) Sep 19, 2026

@pablogsal pablogsal 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.

The release tokenizer fix and interactive buffer retention are included. The final tree matches the debug build tested locally: 702 tests passed, including the CPU-resource cases and the new interactive regression.

@pablogsal
pablogsal enabled auto-merge (squash) September 19, 2026 22:07
@pablogsal
pablogsal merged commit b5cbbb2 into python:3.15 Sep 19, 2026
61 of 62 checks passed
@miss-islington
miss-islington deleted the backport-c1df684-3.15 branch September 19, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants