@@ -894,21 +894,18 @@ dummy_func(void) {
894894 // the result is always a bool, but sometimes we can
895895 // narrow it down to True or False
896896 res = sym_new_type (ctx , & PyBool_Type );
897+ PyTypeObject * inst_type = sym_get_type (instance );
897898 PyTypeObject * cls_o = (PyTypeObject * )sym_get_const (ctx , cls );
898- if (cls_o && sym_matches_type (cls , & PyType_Type )) {
899- // isinstance(obj, cls) where cls is a known class
900- PyTypeObject * inst_type = sym_get_type (instance );
901- if (inst_type ) {
902- // isinstance(obj, cls) where both obj and cls have
903- // known types meaning we can deduce either True or False
904-
905- // The below check is equivalent to PyObject_TypeCheck(inst, cls)
906- if (sym_matches_type (instance , cls_o ) || PyType_IsSubtype (inst_type , cls_o )) {
907- sym_set_const (res , Py_True );
908- }
909- else {
910- sym_set_const (res , Py_False );
911- }
899+ if (inst_type && cls_o && sym_matches_type (cls , & PyType_Type )) {
900+ // isinstance(inst, cls) where both inst and cls have
901+ // known types, meaning we can deduce either True or False
902+
903+ // The below check is equivalent to PyObject_TypeCheck(inst, cls)
904+ if (sym_matches_type (instance , cls_o ) || PyType_IsSubtype (inst_type , cls_o )) {
905+ sym_set_const (res , Py_True );
906+ }
907+ else {
908+ sym_set_const (res , Py_False );
912909 }
913910 }
914911 }
0 commit comments