Skip to content

Commit 899abbb

Browse files
committed
Fix real_is_instance
1 parent c3857ee commit 899abbb

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

vm/src/protocol/object.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,17 @@ impl PyObject {
538538
/// Real isinstance check without going through __instancecheck__
539539
/// This is equivalent to CPython's _PyObject_RealIsInstance/object_isinstance
540540
pub fn real_is_instance(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool> {
541-
if let Ok(typ) = cls.try_to_ref::<PyType>(vm) {
541+
if let Ok(cls) = cls.try_to_ref::<PyType>(vm) {
542542
// PyType_Check(cls) - cls is a type object
543-
let mut retval = self.fast_isinstance(typ);
544-
543+
let mut retval = self.class().is_subtype(cls);
545544
if !retval {
546545
// Check __class__ attribute, only masking AttributeError
547546
if let Some(i_cls) =
548547
vm.get_attribute_opt(self.to_owned(), identifier!(vm, __class__))?
549548
{
550549
if let Ok(i_cls_type) = PyTypeRef::try_from_object(vm, i_cls) {
551550
if !i_cls_type.is(self.class()) {
552-
retval = i_cls_type.fast_issubclass(typ);
551+
retval = i_cls_type.is_subtype(cls);
553552
}
554553
}
555554
}
@@ -568,11 +567,7 @@ impl PyObject {
568567
if let Some(i_cls) =
569568
vm.get_attribute_opt(self.to_owned(), identifier!(vm, __class__))?
570569
{
571-
if vm.is_none(&i_cls) {
572-
Ok(false)
573-
} else {
574-
i_cls.abstract_issubclass(cls, vm)
575-
}
570+
i_cls.abstract_issubclass(cls, vm)
576571
} else {
577572
Ok(false)
578573
}

0 commit comments

Comments
 (0)