File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ fn _mro(cls: PyObjectRef) -> Option<Vec<PyObjectRef>> {
81
81
/// Determines if `obj` actually an instance of `cls`, this doesn't call __instancecheck__, so only
82
82
/// use this if `cls` is known to have not overridden the base __instancecheck__ magic method.
83
83
pub fn isinstance ( obj : & PyObjectRef , cls : & PyObjectRef ) -> bool {
84
- issubclass ( & obj. typ ( ) , & cls)
84
+ issubclass ( obj. type_ref ( ) , & cls)
85
85
}
86
86
87
87
fn type_instance_check ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
Original file line number Diff line number Diff line change @@ -761,19 +761,22 @@ pub trait FromPyObjectRef {
761
761
}
762
762
763
763
pub trait TypeProtocol {
764
- fn typ ( & self ) -> PyObjectRef ;
764
+ fn typ ( & self ) -> PyObjectRef {
765
+ self . type_ref ( ) . clone ( )
766
+ }
767
+ fn type_ref ( & self ) -> & PyObjectRef ;
765
768
}
766
769
767
770
impl TypeProtocol for PyObjectRef {
768
- fn typ ( & self ) -> PyObjectRef {
769
- ( * * self ) . typ ( )
771
+ fn type_ref ( & self ) -> & PyObjectRef {
772
+ ( * * self ) . type_ref ( )
770
773
}
771
774
}
772
775
773
776
impl TypeProtocol for PyObject {
774
- fn typ ( & self ) -> PyObjectRef {
777
+ fn type_ref ( & self ) -> & PyObjectRef {
775
778
match self . typ {
776
- Some ( ref typ) => typ. clone ( ) ,
779
+ Some ( ref typ) => & typ,
777
780
None => panic ! ( "Object {:?} doesn't have a type!" , self ) ,
778
781
}
779
782
}
You can’t perform that action at this time.
0 commit comments