-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add BaseException.__reduce__ #3665
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
Conversation
Looks good! This PR can be a good specimen for the other remaining works. Does "three items" mean |
Yes. I only had to add things to |
Unfortunately, OSError's and ImportError's reduce act different than BaseException's 😭 |
I would direct future contributors to look at the |
Ok good 😊. Except for the issue about the empty set that I commented on, everything seems fine. |
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.
great, thank you! @Snowapril and thank you for the review!
@@ -519,6 +519,15 @@ impl PyBaseException { | |||
let cls = zelf.class(); | |||
format!("{}({})", cls.name(), repr_args.iter().format(", ")) | |||
} | |||
|
|||
#[pymethod(magic)] | |||
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyTupleRef { |
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.
If it doesn't require type checking, this may be:
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyTupleRef { | |
fn reduce(zelf: PyObjectRef, vm: &VirtualMachine) -> PyTupleRef { |
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.
It doesn't work in practice because rustc will complain:
no method named `args` found for struct `core::PyObjectRef` in the current scope
method not found in `core::PyObjectRef`
Addresses three items in #3611.
cc @Snowapril