GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-153569: centralize formatted-string state and source spans by pablogsal · Pull Request #156484 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Aug 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Store formatted-string expressions and comments as source spans. Keep active f/t-string frames with explicit transitions between text, expressions, and format specifications, and derive token locations and failure status from scanner state.

This PR just moves code around and removes the old state.

Part of gh-153569.

First PR in the stack for gh-153569. Next: #156654.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Aug 27, 2026
Base the tokenizer API on source offsets #153569
Open
@pablogsal pablogsal closed this Aug 27, 2026
StanFromIreland
StanFromIreland reviewed Aug 27, 2026
View reviewed changes
Comment thread Modules/_xxtestfuzz/fuzzer.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal pablogsal reopened this Aug 27, 2026
@pablogsal

pablogsal commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Do not review until #156482 lands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal pablogsal added the skip news label Aug 27, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 5505010 to 68400fb Compare August 28, 2026 18:40
@pablogsal pablogsal changed the title gh-153569: add tokenizer validation tools gh-153569: move f-string state to source spans Aug 28, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch 3 times, most recently from 962c0c5 to eae3e33 Compare August 28, 2026 23:48
@pablogsal pablogsal changed the title gh-153569: move f-string state to source spans gh-153569: simplify tokenizer state Aug 29, 2026
@pablogsal pablogsal changed the title gh-153569: simplify tokenizer state gh-153569: simplify tokenizer state and source storage Aug 29, 2026
@pablogsal pablogsal changed the title gh-153569: simplify tokenizer state and source storage gh-153569: simplify tokenizer and formatted-string state Aug 30, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 73741c4 to 3ce81ac Compare August 30, 2026 11:12
@pablogsal pablogsal changed the title gh-153569: simplify tokenizer and formatted-string state gh-153569: store tokenizer state as source spans Aug 30, 2026
@pablogsal pablogsal mentioned this pull request Aug 30, 2026
gh-153569: hide tokenizer state behind token and source operations #156654
Merged
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch 2 times, most recently from 6e223e0 to 64893b4 Compare August 30, 2026 11:26
@pablogsal pablogsal changed the title gh-153569: store tokenizer state as source spans gh-153569: remove unused tokenizer cursor support Aug 30, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 64893b4 to bdeeeb6 Compare August 30, 2026 13:16
@pablogsal pablogsal changed the title gh-153569: remove unused tokenizer cursor support gh-153569: remove the unused tokenizer cursor and line index Aug 30, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch 3 times, most recently from 9318772 to 056e86e Compare September 5, 2026 17:46
@pablogsal pablogsal mentioned this pull request Sep 5, 2026
gh-153569: return token spans and unify decoded source storage #156482
Merged
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch 3 times, most recently from da9dfb7 to 1a1a3c7 Compare September 6, 2026 20:24
@pablogsal
pablogsal marked this pull request as ready for review September 6, 2026 20:31
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 6, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 1a1a3c7 to 3ef307f Compare September 6, 2026 20:57
@pablogsal
pablogsal requested a review from ericsnowcurrently as a code owner September 6, 2026 20:57
@pablogsal pablogsal changed the title gh-153569: remove the unused tokenizer cursor and line index gh-153569: consolidate tokenizer state around source spans Sep 6, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 3ef307f to 177eca5 Compare September 6, 2026 21:37
@pablogsal pablogsal changed the title gh-153569: consolidate tokenizer state around source spans gh-153569: consolidate tokenizer source and lexer state Sep 6, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 0c5a521 to 0b9a33b Compare September 6, 2026 23:35
@pablogsal
pablogsal marked this pull request as draft September 6, 2026 23:37
@pablogsal pablogsal changed the title gh-153569: consolidate tokenizer source and lexer state gh-153569: use source spans and derived tokenizer locations Sep 6, 2026
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 6, 2026
@pablogsal pablogsal mentioned this pull request Sep 6, 2026
gh-153569: consolidate tokenizer reader ownership and source views pablogsal/cpython#138
Closed
pablogsal added 4 commits September 7, 2026 00:47
@pablogsal
pythongh-153569: store formatted-string text as source spans
55da4dd
Formatted-string expressions and comments can outlive the buffer window where
scanning began. Pointer boundaries require buffer relocation to repair tokenizer
state.

Record logical source ranges instead. Retain the active input window while a
formatted string is open, give each mode ownership of its comment spans, and
materialize text through shared span views.
@pablogsal
pythongh-153569: derive tokenizer locations and failures from scanner…
4c8ba41
… state
@pablogsal
pythongh-153569: keep active formatted-string frames
9e645ae
@pablogsal
pythongh-153569: centralize formatted-string transitions
c0ee295
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-validation-tools-clean branch from 0b9a33b to c0ee295 Compare September 7, 2026 00:03
@pablogsal pablogsal changed the title gh-153569: use source spans and derived tokenizer locations gh-153569: centralize formatted-string state and source spans Sep 7, 2026
@pablogsal pablogsal mentioned this pull request Sep 7, 2026
gh-153569: consolidate tokenizer input, layout, and diagnostics #157055
Merged
@pablogsal
pablogsal marked this pull request as ready for review September 7, 2026 22:05
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 7, 2026
@pablogsal
pablogsal merged commit 2ddc218 into python:main Sep 8, 2026
94 of 96 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal deleted the gh-153569-tokenizer-validation-tools-clean branch September 8, 2026 23:15
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 8, 2026
maurycy added a commit to maurycy/cpython that referenced this pull request Sep 10, 2026
@maurycy
Merge branch 'main' into tachyon-native-callable
e028ff5
* main: (158 commits)
  pythongh-156924: Try reifying lazy imports in `ForwarRef.evaluate()` (python#156940)
  pythongh-156233: Fix typos and code snippet errors in the docs (python#156475)
  pythongh-156837: Refer to yield expressions in generator function definitions (pythonGH-156863)
  pythongh-155292: Skip updating unicodedata with mismatched interpreter (pythonGH-157066)
  pythongh-157170: Document the scope of global curses settings (pythonGH-157207)
  pythongh-155966: Correct handling of `math.tanpi` poles (python#155980)
  pythongh-157170: Restore use_env() after test_use_prescr_screen in test_curses (pythonGH-157171)
  pythongh-156910: fix deadlock in type_set_abstractmethods under free-threading (python#156948)
  pythongh-155648: Write the empty and placeholder IDLE tests (python#156260)
  pythongh-153569: centralize formatted-string state and source spans (python#156484)
  pythongh-157137: Mark the PEP 820 soft deprecations as 3.15, not `next` (python#157138)
  pythongh-152433: Use regular LoadLibrary in UWP for Windows system libs (pythonGH-156972)
  pythongh-121617: Fix Py_CLEAR() memcpy in C++: replace NULL with _Py_NULL (python#157188)
  pythongh-157135: Fix documentation errors in the `math.atan{2}pi` functions (python#157136)
  pythongh-121617: Fix Py_CLEAR() in C++: replace NULL with _Py_NULL (python#157067)
  pythongh-156774: Speed up pdb startup with asyncio guard (python#156775)
  pythongh-156109: Allow static, non-framework iOS builds (python#156110)
  pythongh-156780: Emscripten: add missing EM_JS_DEPS (python#156798)
  pythongh-152936: Make privileged functions available on Android (python#152977)
  pythongh-123018: Keep the libedit history file header when truncating (pythonGH-157165)
  ...
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
@pablogsal @clin1234
pythongh-153569: centralize formatted-string state and source spans (p…
632fb08
…ython#156484)

Formatted-string expressions and comments can outlive the buffer window where
scanning began. Pointer boundaries require buffer relocation to repair tokenizer
state. Record logical source ranges instead. Retain the active input window while a
formatted string is open, give each mode ownership of its comment spans, and
materialize text through shared span views.
johnslavik pushed a commit to johnslavik/cpython that referenced this pull request Sep 14, 2026
@pablogsal @johnslavik
pythongh-153569: centralize formatted-string state and source spans (p…
e1b2f00
…ython#156484)

Formatted-string expressions and comments can outlive the buffer window where
scanning began. Pointer boundaries require buffer relocation to repair tokenizer
state. Record logical source ranges instead. Retain the active input window while a
formatted string is open, give each mode ownership of its comment spans, and
materialize text through shared span views.
This was referenced Sep 19, 2026
gh-155525: Cover quadratic f-string tokenization regression #156756
Merged
[3.15] gh-155525: Fix quadratic f-string tokenization (GH-156756) #157828
Merged
[3.14] gh-155525: Fix quadratic f-string tokenization (GH-156756) #157829
Merged
[3.13] gh-155525: Fix quadratic f-string tokenization (GH-156756) #157830
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@StanFromIreland StanFromIreland StanFromIreland left review comments
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland
@AA-Turner AA-Turner Awaiting requested review from AA-Turner
@emmatyping emmatyping Awaiting requested review from emmatyping
@itamaro itamaro Awaiting requested review from itamaro
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pablogsal @StanFromIreland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.