@@ -9,7 +9,7 @@ use crate::pyobject::{
99 IdProtocol , PyClassImpl , PyContext , PyObject , PyObjectRef , PyRef , PyResult , PyValue ,
1010 TypeProtocol ,
1111} ;
12- use crate :: slots:: PyBuiltinDescriptor ;
12+ use crate :: slots:: SlotDescriptor ;
1313use crate :: vm:: VirtualMachine ;
1414
1515// Read-only property, doesn't have __set__ or __delete__
@@ -27,13 +27,14 @@ impl PyValue for PyReadOnlyProperty {
2727
2828pub type PyReadOnlyPropertyRef = PyRef < PyReadOnlyProperty > ;
2929
30- impl PyBuiltinDescriptor for PyReadOnlyProperty {
31- fn get (
32- zelf : PyRef < Self > ,
33- obj : PyObjectRef ,
34- cls : OptionalArg < PyObjectRef > ,
30+ impl SlotDescriptor for PyReadOnlyProperty {
31+ fn descr_get (
3532 vm : & VirtualMachine ,
33+ zelf : PyObjectRef ,
34+ obj : Option < PyObjectRef > ,
35+ cls : OptionalArg < PyObjectRef > ,
3636 ) -> PyResult {
37+ let ( zelf, obj) = Self :: _unwrap ( zelf, obj, vm) ?;
3738 if vm. is_none ( & obj) {
3839 if Self :: _cls_is ( & cls, & vm. ctx . types . type_type ) {
3940 vm. invoke ( & zelf. getter , cls. unwrap ( ) )
@@ -46,7 +47,7 @@ impl PyBuiltinDescriptor for PyReadOnlyProperty {
4647 }
4748}
4849
49- #[ pyimpl( with( PyBuiltinDescriptor ) ) ]
50+ #[ pyimpl( with( SlotDescriptor ) ) ]
5051impl PyReadOnlyProperty { }
5152
5253/// Property attribute.
@@ -110,13 +111,14 @@ struct PropertyArgs {
110111 doc : Option < PyObjectRef > ,
111112}
112113
113- impl PyBuiltinDescriptor for PyProperty {
114- fn get (
115- zelf : PyRef < Self > ,
116- obj : PyObjectRef ,
117- _cls : OptionalArg < PyObjectRef > ,
114+ impl SlotDescriptor for PyProperty {
115+ fn descr_get (
118116 vm : & VirtualMachine ,
117+ zelf : PyObjectRef ,
118+ obj : Option < PyObjectRef > ,
119+ _cls : OptionalArg < PyObjectRef > ,
119120 ) -> PyResult {
121+ let ( zelf, obj) = Self :: _unwrap ( zelf, obj, vm) ?;
120122 if let Some ( getter) = zelf. getter . as_ref ( ) {
121123 if obj. is ( vm. ctx . none . as_object ( ) ) {
122124 Ok ( zelf. into_object ( ) )
@@ -129,7 +131,7 @@ impl PyBuiltinDescriptor for PyProperty {
129131 }
130132}
131133
132- #[ pyimpl( with( PyBuiltinDescriptor ) , flags( BASETYPE ) ) ]
134+ #[ pyimpl( with( SlotDescriptor ) , flags( BASETYPE ) ) ]
133135impl PyProperty {
134136 #[ pyslot]
135137 fn tp_new ( cls : PyClassRef , args : PropertyArgs , vm : & VirtualMachine ) -> PyResult < PyPropertyRef > {
0 commit comments