@@ -473,7 +473,7 @@ fn impl_clear_slot(cls: &syn::Type, spec: &FnSpec<'_>, ctx: &Ctx) -> syn::Result
473473 _ => bail_spanned ! ( spec. name. span( ) => "expected instance method for `__clear__` function" ) ,
474474 } ;
475475 let mut holders = Holders :: new ( ) ;
476- let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , & mut holders, ctx) ;
476+ let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , false , & mut holders, ctx) ;
477477
478478 if let [ arg, ..] = args {
479479 bail_spanned ! ( arg. ty( ) . span( ) => "`__clear__` function expected to have no arguments" ) ;
@@ -571,7 +571,7 @@ fn impl_call_setter(
571571 ctx : & Ctx ,
572572) -> syn:: Result < TokenStream > {
573573 let ( py_arg, args) = split_off_python_arg ( & spec. signature . arguments ) ;
574- let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , holders, ctx) ;
574+ let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , false , holders, ctx) ;
575575
576576 if args. is_empty ( ) {
577577 bail_spanned ! ( spec. name. span( ) => "setter function expected to have one argument" ) ;
@@ -611,7 +611,7 @@ pub fn impl_py_setter_def(
611611 span : Span :: call_site ( ) ,
612612 non_null : true ,
613613 }
614- . receiver ( cls, ExtractErrorMode :: Raise , & mut holders, ctx) ;
614+ . receiver ( cls, ExtractErrorMode :: Raise , false , & mut holders, ctx) ;
615615 if let Some ( ident) = & field. ident {
616616 // named struct field
617617 quote ! ( { #slf. #ident = _val; } )
@@ -757,7 +757,7 @@ fn impl_call_getter(
757757 ctx : & Ctx ,
758758) -> syn:: Result < TokenStream > {
759759 let ( py_arg, args) = split_off_python_arg ( & spec. signature . arguments ) ;
760- let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , holders, ctx) ;
760+ let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , false , holders, ctx) ;
761761 ensure_spanned ! (
762762 args. is_empty( ) ,
763763 args[ 0 ] . ty( ) . span( ) => "getter function can only have one argument (of type pyo3::Python)"
@@ -932,7 +932,7 @@ fn impl_call_deleter(
932932 ctx : & Ctx ,
933933) -> Result < TokenStream > {
934934 let ( py_arg, args) = split_off_python_arg ( & spec. signature . arguments ) ;
935- let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , holders, ctx) ;
935+ let slf = self_type. receiver ( cls, ExtractErrorMode :: Raise , false , holders, ctx) ;
936936
937937 if !args. is_empty ( ) {
938938 bail_spanned ! ( spec. name. span( ) =>
@@ -1395,6 +1395,10 @@ impl SlotDef {
13951395 spec,
13961396 calling_convention,
13971397 * extract_error_mode,
1398+ matches ! (
1399+ calling_convention,
1400+ SlotCallingConvention :: FixedArguments ( & [ Ty :: MaybeNullObject , Ty :: MaybeNullObject ] )
1401+ ) ,
13981402 & mut holders,
13991403 return_mode. as_ref ( ) ,
14001404 ctx,
@@ -1425,11 +1429,16 @@ impl SlotDef {
14251429 }
14261430}
14271431
1432+ #[ allow(
1433+ clippy:: too_many_arguments,
1434+ reason = "slot wrapper generation needs the descriptor fast-path flag"
1435+ ) ]
14281436fn generate_method_body (
14291437 cls : & syn:: Type ,
14301438 spec : & FnSpec < ' _ > ,
14311439 calling_convention : & SlotCallingConvention ,
14321440 extract_error_mode : ExtractErrorMode ,
1441+ descriptor_slot_receiver : bool ,
14331442 holders : & mut Holders ,
14341443 // NB ignored if calling_convention is SlotCallingConvention::TpNew, possibly should merge into that enum
14351444 return_mode : Option < & ReturnMode > ,
@@ -1439,9 +1448,13 @@ fn generate_method_body(
14391448 pyo3_path,
14401449 output_span,
14411450 } = ctx;
1442- let self_arg = spec
1443- . tp
1444- . self_arg ( Some ( cls) , extract_error_mode, holders, ctx) ;
1451+ let self_arg = spec. tp . self_arg (
1452+ Some ( cls) ,
1453+ extract_error_mode,
1454+ descriptor_slot_receiver,
1455+ holders,
1456+ ctx,
1457+ ) ;
14451458 let rust_name = spec. name ;
14461459 let warnings = spec. warnings . build_py_warning ( ctx) ;
14471460
@@ -1621,6 +1634,7 @@ impl SlotFragmentDef {
16211634 spec,
16221635 & SlotCallingConvention :: FixedArguments ( arguments) ,
16231636 * extract_error_mode,
1637+ matches ! ( * fragment, "__set__" | "__delete__" ) ,
16241638 & mut holders,
16251639 None ,
16261640 ctx,
0 commit comments