Repository navigation
Preserve numeric warning error precedence in AST single mode - #9303
Merged
youknowone merged 1 commit intoOct 22, 2026
Merged
youknowone merged 1 commit into
youknowone merged 1 commit into
Conversation
Match ordinary single compilation by allowing later numeric warnings raised as errors to take precedence after a parser-origin escape warning. Preserve tokenizer-origin guards and the separate prompt path. Assisted-by: Codex:unknown
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 22, 2026
youknowone
approved these changes
Oct 22, 2026
youknowone
marked this pull request as ready for review
October 22, 2026 14:23
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Follow up #9296 by allowing numeric-warning recovery in
compile(..., 'single', ast.PyCF_ONLY_AST).When a parser-origin escape warning becomes an error, CPython still scans for later numeric tokenizer warnings raised as errors. The ordinary compilation path already preserves that precedence, but the AST path only enabled it for file/eval input. Include Single in that existing allowlist. This also matters when the numeric warning is on a later logical line.
The patch does not change normal warning-emission boundaries. In particular, the remaining cases that emit warnings from a second statement are separate work. Prompt-interactive input and FuncType retain their existing paths.
Validation
Compared against final CPython 3.15.0, pinned at
d220409a13b77de7a6c30abe16ea90db01528edc, and the source-bound historical #9296 implementation ateb79fef279d646aedf5fca6598d330b54a401138. Candidate is based on main0b0a3607648b5b01b3adfc1c06f3bec1d87f8a13; the historical baseline is not presented as current main.test_compile.TestSpecificsmethods passed:test_single_statement,test_bad_single_statement,test_compile_ast, andtest_compile_warnings. Four tests ran with no skips, expected failures, unexpected successes, errors or failures.No full Python test modules, Rust test execution, workspace/CAPI suites, Windows/macOS/WASM/Miri execution or performance benchmark was run for this patch. The scoped test-target gate compiles tests; it does not execute them.
Limits
Parser-invalid collection and tokenizer-origin f-string warning guards remain in place. AST emission does not itself gate on
has_valid_syntax, so this is not a claim about every malformed-source case. Pre-parse safety paths were source-reviewed, not exercised with deep/hazardous inputs.Non-SyntaxWarning callback exceptions still return directly. A callback-raised SyntaxWarning or subclass qualifies for the same existing type-based recovery as a filter-escalated warning, so AST Single can now proceed to later numeric-warning handling in that case. Custom-callback parity with CPython is not established by these observations.
This does not fix the ten observed statement-boundary cases, numeric offset/text metadata, exception args/repr, or the separate invalid-source recovery gaps. No Lib assertions or expected-failure markers were changed.
AI assistance
This change was prepared and validated with OpenAI Codex assistance.