Repository navigation
Support pickling slot wrapper descriptors #9037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2062,6 +2062,16 @@ impl Callable for PyWrapper { | |
| flags(DISALLOW_INSTANTIATION) | ||
| )] | ||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| let args = vm.ctx.new_tuple(vec![ | ||
| self.typ.to_owned().into(), | ||
| self.name.to_owned().into(), | ||
| ]); | ||
| Ok(vm.ctx.new_tuple(vec![getattr, args.into()]).into()) | ||
| } | ||
|
|
||
| #[pygetset] | ||
| fn __qualname__(&self) -> String { | ||
| format!("{}.{}", self.typ.name(), self.name) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,7 @@ | |
| assert list(memo) == [1, 7] | ||
| assert memo[1] is left | ||
| assert memo[7] is left | ||
|
|
||
| # Slot wrapper descriptors reduce to lookup on their defining class. | ||
| assert object.__str__.__reduce__() == (getattr, (object, "__str__")) | ||
| assert _pickle.loads(_pickle.dumps(object.__str__)) is object.__str__ | ||
|
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit explicitly states that its implementation and review were AI-assisted, but its message has no
Assisted-by: AGENT_NAME:MODEL_VERSIONtrailer; 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 👍 / 👎.