@@ -34,7 +34,7 @@ pub fn gen_py_method(
34
34
} ;
35
35
36
36
let text_signature = match & spec. tp {
37
- FnType :: Fn | FnType :: PySelf ( _) | FnType :: FnClass | FnType :: FnStatic => {
37
+ FnType :: Fn | FnType :: PySelfNew ( _) | FnType :: FnClass | FnType :: FnStatic => {
38
38
utils:: parse_text_signature_attrs ( & mut * meth_attrs, name) ?
39
39
}
40
40
FnType :: FnNew => parse_erroneous_text_signature (
@@ -59,7 +59,7 @@ pub fn gen_py_method(
59
59
60
60
Ok ( match spec. tp {
61
61
FnType :: Fn => impl_py_method_def ( name, doc, & spec, & impl_wrap ( cls, name, & spec, true ) ) ,
62
- FnType :: PySelf ( ref self_ty) => impl_py_method_def (
62
+ FnType :: PySelfNew ( ref self_ty) => impl_py_method_def (
63
63
name,
64
64
doc,
65
65
& spec,
@@ -127,7 +127,7 @@ pub fn impl_wrap_pyslf(
127
127
cls : & syn:: Type ,
128
128
name : & syn:: Ident ,
129
129
spec : & FnSpec < ' _ > ,
130
- self_ty : & syn:: TypePath ,
130
+ self_ty : & syn:: TypeReference ,
131
131
noargs : bool ,
132
132
) -> TokenStream {
133
133
let names = get_arg_names ( spec) ;
@@ -221,8 +221,7 @@ pub fn impl_proto_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) ->
221
221
/// Generate class method wrapper (PyCFunction, PyCFunctionWithKeywords)
222
222
pub fn impl_wrap_new ( cls : & syn:: Type , name : & syn:: Ident , spec : & FnSpec < ' _ > ) -> TokenStream {
223
223
let names: Vec < syn:: Ident > = get_arg_names ( & spec) ;
224
- let cb = quote ! { #cls:: #name( & _obj, #( #names) , * ) } ;
225
-
224
+ let cb = quote ! { #cls:: #name( #( #names) , * ) } ;
226
225
let body = impl_arg_params ( spec, cb) ;
227
226
228
227
quote ! {
@@ -240,11 +239,11 @@ pub fn impl_wrap_new(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec<'_>) -> T
240
239
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
241
240
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
242
241
243
- #body
242
+ # body
244
243
245
- match <<#cls as pyo3:: PyTypeInfo > :: ConcreteLayout as pyo3 :: pyclass :: PyClassNew > :: new( _py, _result ) {
246
- Ok ( _slf ) => _slf as _,
247
- Err ( e) => e. restore_and_null( ) ,
244
+ match _result . and_then ( |slf| pyo3:: PyClassShell :: new( _py, slf ) ) {
245
+ Ok ( slf ) => slf as _,
246
+ Err ( e) => e. restore_and_null( _py ) ,
248
247
}
249
248
}
250
249
}
0 commit comments