@@ -17,7 +17,7 @@ use crate::{
1717 borrow:: BorrowedValue ,
1818 lock:: { PyRwLock , PyRwLockReadGuard } ,
1919 } ,
20- convert:: { ToPyObject , ToPyResult } ,
20+ convert:: ToPyResult ,
2121 function:: { FuncArgs , KwArgs , OptionalArg , PySetterValue } ,
2222 identifier,
2323 protocol:: { PyIterReturn , PyMappingMethods , PyNumberMethods , PySequenceMethods } ,
@@ -816,7 +816,7 @@ impl PyType {
816816 cell. class( ) . name( )
817817 ) )
818818 } ) ?;
819- cell. set ( Some ( typ. clone ( ) . to_pyobject ( vm ) ) ) ;
819+ cell. set ( Some ( typ. clone ( ) . into ( ) ) ) ;
820820 } ;
821821
822822 // avoid deadlock
@@ -844,7 +844,7 @@ impl PyType {
844844
845845 if let Some ( init_subclass) = typ. get_super_attr ( identifier ! ( vm, __init_subclass__) ) {
846846 let init_subclass = vm
847- . call_get_descriptor_specific ( init_subclass. clone ( ) , None , Some ( typ. clone ( ) . into ( ) ) )
847+ . call_get_descriptor_specific ( & init_subclass, None , Some ( typ. clone ( ) . into ( ) ) )
848848 . unwrap_or ( Ok ( init_subclass) ) ?;
849849 init_subclass. call ( kwargs, vm) ?;
850850 } ;
@@ -1008,19 +1008,17 @@ impl GetAttr for PyType {
10081008
10091009 let zelf_attr = zelf. get_attr ( name) ;
10101010
1011- if let Some ( ref attr) = zelf_attr {
1011+ if let Some ( attr) = zelf_attr {
10121012 let descr_get = attr. class ( ) . mro_find_map ( |cls| cls. slots . descr_get . load ( ) ) ;
10131013 if let Some ( descr_get) = descr_get {
1014- return descr_get ( attr. clone ( ) , None , Some ( zelf. to_owned ( ) . into ( ) ) , vm) ;
1014+ descr_get ( attr, None , Some ( zelf. to_owned ( ) . into ( ) ) , vm)
1015+ } else {
1016+ Ok ( attr)
10151017 }
1016- }
1017-
1018- if let Some ( cls_attr) = zelf_attr {
1019- Ok ( cls_attr)
10201018 } else if let Some ( attr) = mcl_attr {
1021- vm. call_if_get_descriptor ( attr, zelf. to_owned ( ) . into ( ) )
1019+ vm. call_if_get_descriptor ( & attr, zelf. to_owned ( ) . into ( ) )
10221020 } else {
1023- return Err ( attribute_error ( zelf, name_str. as_str ( ) , vm) ) ;
1021+ Err ( attribute_error ( zelf, name_str. as_str ( ) , vm) )
10241022 }
10251023 }
10261024}
@@ -1037,7 +1035,7 @@ impl SetAttr for PyType {
10371035 if let Some ( attr) = zelf. get_class_attr ( attr_name) {
10381036 let descr_set = attr. class ( ) . mro_find_map ( |cls| cls. slots . descr_set . load ( ) ) ;
10391037 if let Some ( descriptor) = descr_set {
1040- return descriptor ( attr, zelf. to_owned ( ) . into ( ) , value, vm) ;
1038+ return descriptor ( & attr, zelf. to_owned ( ) . into ( ) , value, vm) ;
10411039 }
10421040 }
10431041 let assign = value. is_assign ( ) ;
@@ -1132,10 +1130,10 @@ fn find_base_dict_descr(cls: &Py<PyType>, vm: &VirtualMachine) -> Option<PyObjec
11321130fn subtype_get_dict ( obj : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
11331131 // TODO: obj.class().as_pyref() need to be supported
11341132 let ret = match find_base_dict_descr ( obj. class ( ) , vm) {
1135- Some ( descr) => vm. call_get_descriptor ( descr, obj) . unwrap_or_else ( |obj | {
1133+ Some ( descr) => vm. call_get_descriptor ( & descr, obj) . unwrap_or_else ( || {
11361134 Err ( vm. new_type_error ( format ! (
11371135 "this __dict__ descriptor does not support '{}' objects" ,
1138- obj . class( )
1136+ descr . class( )
11391137 ) ) )
11401138 } ) ?,
11411139 None => object:: object_get_dict ( obj, vm) ?. into ( ) ,
@@ -1156,7 +1154,7 @@ fn subtype_set_dict(obj: PyObjectRef, value: PyObjectRef, vm: &VirtualMachine) -
11561154 cls. name( )
11571155 ) )
11581156 } ) ?;
1159- descr_set ( descr, obj, PySetterValue :: Assign ( value) , vm)
1157+ descr_set ( & descr, obj, PySetterValue :: Assign ( value) , vm)
11601158 }
11611159 None => {
11621160 object:: object_set_dict ( obj, value. try_into_value ( vm) ?, vm) ?;
0 commit comments