Repository navigation
Align mapping boundaries with Python 3.15 final - #9128
Conversation
Support frozen mappings in str.maketrans and native JSON encoding, preserve integer translation keys, and protect mappingproxy dictionaries from unknown reflected comparisons. Assisted-by: OpenAI Codex:model version unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 5
✨ 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 |
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: e9f99cc388
ℹ️ 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".
| && obj.class().is(vm.ctx.types.dict_type) | ||
| && !(other.class().is(vm.ctx.types.dict_type) | ||
| || other.class().is(vm.ctx.types.frozendict_type) | ||
| || other.class().is(vm.ctx.types.mappingproxy_type) |
There was a problem hiding this comment.
Validate the mapping inside a whitelisted proxy
When other is an exact mappingproxy around an untrusted mapping, this exemption still exposes the protected dictionary: for MappingProxyType(victim) == MappingProxyType(Evil()), the outer slot skips the copy here, dict comparison returns NotImplemented, and the reflected proxy unwraps Evil, whose __eq__ then receives the original victim and can call clear() on it. Only exempt another proxy after verifying that its wrapped mapping is itself a known safe fast path (or remove this exemption), otherwise the reflected-callback protection is bypassable.
Useful? React with 👍 / 👎.
Summary
Extract related mapping-boundary compatibility changes from #8954, following CPython v3.15.0 final:
str.maketrans, retain integer key objects, and raise the correct exception for unsupported inputs..items()dispatch.The only supporting change exposes PyOrderedDict within the VM crate for the exact-type comparison. No
Lib/or test files change. JSON array hooks and the pure-Python encoder remain separate work.Validation
-D warnings: passed.git diff --check: passed.The initial extraction failed compilation because PyOrderedDict was private on main. Its two crate-local visibility/re-export prerequisites are included; no payload fields or OrderedDict implementation changed.
Canonical methods/helpers were copied unchanged into external bounded runners and verified against final d220409a13b77de7a6c30abe16ea90db01528edc. Full workspace/C-API suites, other platforms, concurrency/stress tests and broad JSON mutation semantics were not run locally; hosted CI remains required. Arbitrary-size integer-key preservation, integer-subclass identity and rejection of mapping subclasses in maketrans were source-reviewed, not covered by these selectors. JSON validation covers the native encoder only.
AI-assisted implementation and validation with OpenAI Codex.