Repository navigation
Support pickling slot wrapper descriptors - #9037
Conversation
Extract wrapper descriptor reduction from RustPython#8954 for Python 3.14. Reduce to getattr on the defining class and cover direct reduction plus one roundtrip in the existing pickle snippet. Preserve canonical expected failures for unrelated staticmethod descriptor behavior. Assisted-by: OpenAI Codex:model identifier unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ 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: f1a9ecada7
ℹ️ 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".
| )] | ||
| impl Py<PyWrapper> { | ||
| #[pymethod] | ||
| fn __reduce__(&self, vm: &VirtualMachine) -> PyResult { |
There was a problem hiding this comment.
Add the required AI-assistance trailer
This commit explicitly states that its implementation and review were AI-assisted, but its message has no Assisted-by: AGENT_NAME:MODEL_VERSION trailer; the repository requires that exact trailer format for every AI-assisted contribution, so rewrite the commit message before merging.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
| assert object.__str__.__reduce__() == (getattr, (object, "__str__")) | ||
| assert _pickle.loads(_pickle.dumps(object.__str__)) is object.__str__ |
There was a problem hiding this comment.
Remove the forbidden test assertions
These lines add new assertion logic to a test file, but the repository rules prohibit test assertion/logic edits and state that the only acceptable test-file changes are adding or removing expected-failure markers; remove these assertions or obtain an explicit policy exception before merging.
AGENTS.md reference: AGENTS.md:L275-L279
Useful? React with 👍 / 👎.
| impl Py<PyWrapper> { | ||
| #[pymethod] | ||
| fn __reduce__(&self, vm: &VirtualMachine) -> PyResult { | ||
| let getattr = vm.builtins.get_attr("getattr", vm)?; |
There was a problem hiding this comment.
Resolve
getattr from the current frame's builtins
When __reduce__ is called from an exec/eval frame whose custom __builtins__ mapping overrides or omits getattr, CPython uses that frame-local value (or raises AttributeError), whereas this lookup always reads the interpreter's global builtins module. VirtualMachine::eval_get_builtin already implements the required _PyEval_GetBuiltin semantics, so using the module directly here returns or serializes the wrong callable in custom-builtins contexts.
Useful? React with 👍 / 👎.
Follow up on RustPython#9037 by using the existing frame-aware builtin lookup. Assisted-by: OpenAI Codex:model identifier unavailable
Follow up on RustPython#9037 by using the existing frame-aware builtin lookup. Assisted-by: OpenAI Codex:model identifier unavailable
Follow up on RustPython#9037 by using the existing frame-aware builtin lookup. Assisted-by: OpenAI Codex:model identifier unavailable
Support pickling slot wrapper descriptors such as
object.__str__, matching CPython 3.14. Reduce each descriptor togetattron its defining class.Extracted from #8954. Adds direct reduction and one roundtrip assertion to the existing pickle snippet. Canonical expected-failure markers remain because those tests also expose unrelated staticmethod-descriptor failures.
Validation:
TypeErrorfor wrapper descriptor reduction.AI-assisted implementation, tests, and review with OpenAI Codex. Kept as a draft for CI and maintainer review.