@@ -2,7 +2,7 @@ use super::{PyStrRef, PyType, PyTypeRef, PyWeak};
22use crate :: {
33 class:: PyClassImpl ,
44 function:: OptionalArg ,
5- types:: { Constructor , SetAttr } ,
5+ types:: { Constructor , GetAttr , SetAttr } ,
66 Context , Py , PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
77} ;
88
@@ -57,14 +57,8 @@ crate::common::static_cell! {
5757 static WEAK_SUBCLASS : PyTypeRef ;
5858}
5959
60- #[ pyimpl( with( SetAttr , Constructor ) ) ]
60+ #[ pyimpl( with( GetAttr , SetAttr , Constructor ) ) ]
6161impl PyWeakProxy {
62- // TODO: callbacks
63- #[ pymethod( magic) ]
64- fn getattr ( & self , attr_name : PyStrRef , vm : & VirtualMachine ) -> PyResult {
65- let obj = self . weak . upgrade ( ) . ok_or_else ( || new_reference_error ( vm) ) ?;
66- obj. get_attr ( attr_name, vm)
67- }
6862 #[ pymethod( magic) ]
6963 fn str ( & self , vm : & VirtualMachine ) -> PyResult < PyStrRef > {
7064 match self . weak . upgrade ( ) {
@@ -81,6 +75,14 @@ fn new_reference_error(vm: &VirtualMachine) -> PyRef<super::PyBaseException> {
8175 )
8276}
8377
78+ impl GetAttr for PyWeakProxy {
79+ // TODO: callbacks
80+ fn getattro ( zelf : & Py < Self > , name : PyStrRef , vm : & VirtualMachine ) -> PyResult {
81+ let obj = zelf. weak . upgrade ( ) . ok_or_else ( || new_reference_error ( vm) ) ?;
82+ obj. get_attr ( name, vm)
83+ }
84+ }
85+
8486impl SetAttr for PyWeakProxy {
8587 fn setattro (
8688 zelf : & crate :: Py < Self > ,
0 commit comments