@@ -528,10 +528,36 @@ public boolean isInstance(Object cls, Object instance) {
528
528
@ GenerateNodeFactory
529
529
static abstract class SubclassCheckNode extends PythonBinaryBuiltinNode {
530
530
@ Child private IsSubtypeNode isSubtypeNode = IsSubtypeNode .create ();
531
+ @ Child private TypeNodes .IsSameTypeNode isSameTypeNode = TypeNodes .IsSameTypeNode .create ();
532
+
533
+ @ Specialization (guards = {"!isNativeClass(cls)" , "!isNativeClass(derived)" })
534
+ boolean doManagedManaged (LazyPythonClass cls , LazyPythonClass derived ) {
535
+ return isSameType (cls , derived ) || isSubtypeNode .execute (derived , cls );
536
+ }
531
537
532
538
@ Specialization
533
- boolean instanceCheck (LazyPythonClass cls , Object derived ) {
534
- return cls == derived || isSubtypeNode .execute (derived , cls );
539
+ boolean doObjectObject (Object cls , Object derived ,
540
+ @ Cached ("create()" ) TypeNodes .IsTypeNode isClsTypeNode ,
541
+ @ Cached ("create()" ) TypeNodes .IsTypeNode isDerivedTypeNode ) {
542
+ if (isSameType (cls , derived )) {
543
+ return true ;
544
+ }
545
+
546
+ // no profiles required because IsTypeNode profiles already
547
+ if (isClsTypeNode .execute (cls ) && isDerivedTypeNode .execute (derived )) {
548
+ return isSubtypeNode .execute (derived , cls );
549
+ }
550
+ if (!isDerivedTypeNode .execute (derived )) {
551
+ throw raise (PythonBuiltinClassType .TypeError , "issubclass() arg 1 must be a class" );
552
+ }
553
+ if (!isClsTypeNode .execute (cls )) {
554
+ throw raise (PythonBuiltinClassType .TypeError , "issubclass() arg 2 must be a class or tuple of classes" );
555
+ }
556
+ return false ;
557
+ }
558
+
559
+ protected boolean isSameType (Object a , Object b ) {
560
+ return isSameTypeNode .execute (a , b );
535
561
}
536
562
}
537
563
0 commit comments