File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -81,8 +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
- let mro = _mro ( obj. typ ( ) ) . unwrap ( ) ;
85
- mro. into_iter ( ) . any ( |c| c. is ( & cls) )
84
+ issubclass ( & obj. typ ( ) , & cls)
86
85
}
87
86
88
87
fn type_instance_check ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
@@ -98,8 +97,8 @@ fn type_instance_check(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
98
97
/// so only use this if `cls` is known to have not overridden the base __subclasscheck__ magic
99
98
/// method.
100
99
pub fn issubclass ( subclass : & PyObjectRef , cls : & PyObjectRef ) -> bool {
101
- let mro = _mro ( subclass. clone ( ) ) . unwrap ( ) ;
102
- mro. into_iter ( ) . any ( |c| c. is ( & cls) )
100
+ let ref mro = subclass. payload :: < PyClass > ( ) . unwrap ( ) . mro ;
101
+ subclass . is ( & cls ) || mro. iter ( ) . any ( |c| c. is ( & cls) )
103
102
}
104
103
105
104
fn type_subclass_check ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
You can’t perform that action at this time.
0 commit comments