File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*! Python `property` descriptor class.
22
33*/
4- use super :: { PyStrRef , PyType , PyTypeRef } ;
4+ use super :: { PyType , PyTypeRef } ;
55use crate :: common:: lock:: PyRwLock ;
6+ use crate :: function:: PosArgs ;
67use crate :: {
78 class:: PyClassImpl ,
89 function:: { FuncArgs , PySetterValue } ,
@@ -55,14 +56,6 @@ impl GetDescriptor for PyProperty {
5556 }
5657}
5758
58- #[ derive( FromArgs ) ]
59- struct SetNameArgs {
60- #[ pyarg( positional) ]
61- owner : PyObjectRef ,
62- #[ pyarg( positional) ]
63- str : PyStrRef ,
64- }
65-
6659#[ pyclass( with( Constructor , Initializer , GetDescriptor ) , flags( BASETYPE ) ) ]
6760impl PyProperty {
6861 // Descriptor methods
@@ -131,8 +124,20 @@ impl PyProperty {
131124 }
132125
133126 #[ pymethod( magic) ]
134- fn set_name ( & self , _args : SetNameArgs , _vm : & VirtualMachine ) -> PyResult < ( ) > {
135- Ok ( ( ) )
127+ fn set_name ( & self , args : PosArgs , vm : & VirtualMachine ) -> PyResult < ( ) > {
128+ let arg_len = args. into_vec ( ) . len ( ) ;
129+
130+ if arg_len != 2 {
131+ Err ( vm. new_exception_msg (
132+ vm. ctx . exceptions . type_error . to_owned ( ) ,
133+ format ! (
134+ "__set_name__() takes 2 positional arguments but {} were given" ,
135+ arg_len
136+ ) ,
137+ ) )
138+ } else {
139+ Ok ( ( ) )
140+ }
136141 }
137142
138143 // Python builder functions
You can’t perform that action at this time.
0 commit comments