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 :: { PyType , PyTypeRef } ;
4+ use super :: { PyStrRef , PyType , PyTypeRef } ;
55use crate :: common:: lock:: PyRwLock ;
6- use crate :: function:: PosArgs ;
76use crate :: {
87 class:: PyClassImpl ,
98 function:: { FuncArgs , PySetterValue } ,
@@ -88,6 +87,14 @@ impl GetDescriptor for PyProperty {
8887 }
8988}
9089
90+ #[ derive( FromArgs ) ]
91+ struct SetNameArgs {
92+ #[ pyarg( positional) ]
93+ owner : PyObjectRef ,
94+ #[ pyarg( positional) ]
95+ str : PyStrRef ,
96+ }
97+
9198#[ pyclass( with( Constructor , Initializer , GetDescriptor ) , flags( BASETYPE ) ) ]
9299impl PyProperty {
93100 // Descriptor methods
@@ -156,20 +163,8 @@ impl PyProperty {
156163 }
157164
158165 #[ pymethod( magic) ]
159- fn set_name ( & self , args : PosArgs , vm : & VirtualMachine ) -> PyResult < ( ) > {
160- let arg_len = args. into_vec ( ) . len ( ) ;
161-
162- if arg_len != 2 {
163- Err ( vm. new_exception_msg (
164- vm. ctx . exceptions . type_error . to_owned ( ) ,
165- format ! (
166- "__set_name__() takes 2 positional arguments but {} were given" ,
167- arg_len
168- ) ,
169- ) )
170- } else {
171- Ok ( ( ) )
172- }
166+ fn set_name ( & self , _args : SetNameArgs , _vm : & VirtualMachine ) -> PyResult < ( ) > {
167+ Ok ( ( ) )
173168 }
174169
175170 // Python builder functions
You can’t perform that action at this time.
0 commit comments