Repository navigation
Align JSON encoder callback state with Python 3.15 - #9671
youknowdot wants to merge 1 commit into
Conversation
Retain caller markers, preserve callback-visible iteration and error state, and reuse shared flag conversion and list sorting. Assisted-by: OpenAI Codex:model version not exposed
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
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. |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2c208c0d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| item_separator: PyStrRef, | ||
| #[pyarg(any)] | ||
| sort_keys: PyObjectRef, | ||
| sort_keys: ArgIntoBool, |
There was a problem hiding this comment.
Reject surplus keywords before coercing encoder flags
When all nine parameters are supplied together with an unexpected keyword, FuncArgs::bind_for() only prechecks the positional count and rejects leftover keywords after T::from_args(). These ArgIntoBool fields therefore invoke a flag's __bool__ before rejecting the invalid call. If that callback raises, its exception escapes instead of the TypeError returned before this commit and by the CPython reference; otherwise, its side effects still run unexpectedly. Preflight the surplus-keyword/total-argument check before converting the flags, while preserving the intended conversion order for valid calls.
Useful? React with 👍 / 👎.
Summary
Align the native JSON encoder's callback-visible state with Python 3.15:
items(), sort it using the shared list implementation, and validate pairs as they are consumed.ArgIntoBoolbinding helper before constructor validation.The change reuses the VM's mapping, list sorting, dictionary iteration and native dictionary helpers. It makes the existing native dictionary deletion helper available to the standard-library crate rather than duplicating its implementation.
Reference behavior is defined by CPython's encoder construction, default callback handling, and mapping iteration.
Validation
cargo check --locked --offline -j1 -p rustpython-stdlib --features rustpython-stdlib/threadingpassed.cargo clippy --locked --offline -j1 -p rustpython-vm -p rustpython-host_env -p rustpython-stdlib --features rustpython-stdlib/threading -- -D warningspassed.AI assistance: OpenAI Codex assisted with source comparison, implementation and reference probes under maintainer direction.