-
Notifications
You must be signed in to change notification settings - Fork 792
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
Use subclass correctly in tp_new #990
Conversation
3eade55
to
b27f713
Compare
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.
👍 Nicely fixed!
pyo3-derive-backend/src/pymethod.rs
Outdated
@@ -193,7 +193,7 @@ pub fn impl_wrap_new(cls: &syn::Type, spec: &FnSpec<'_>) -> TokenStream { | |||
quote! { | |||
#[allow(unused_mut)] | |||
unsafe extern "C" fn __wrap( | |||
_cls: *mut pyo3::ffi::PyTypeObject, | |||
subcls: *mut pyo3::ffi::PyTypeObject, |
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.
I think it's better to keep the cls
name convention maybe.
subcls: *mut pyo3::ffi::PyTypeObject, | |
cls: *mut pyo3::ffi::PyTypeObject, |
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.
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.
Ah yes good find 👍 I think subtype is probably better than cls
here and also for create_cell_with_type
in that case!
Thank you for the reviews 👍 |
Fixes #947.
As documented, we have to call
subtype->tp_alloc(subtype, nitems)
in tp_new.In this PR, I also renamed
PyClassAlloc::alloc
tonew
, since it does not actually overridetp_alloc
.