diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 82a48ad4d1a..ab05112f1fd 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -2173,12 +2173,6 @@ class ClassPropertiesAndMethods(unittest.TestCase): return 1j def stop(self): raise StopIteration - def return_true(self, thing=None): - return True - def do_isinstance(obj): - return isinstance(int, obj) - def do_issubclass(obj): - return issubclass(int, obj) def do_dict_missing(checker): class DictSub(checker.__class__, dict): pass @@ -2199,11 +2193,8 @@ class ClassPropertiesAndMethods(unittest.TestCase): ("__length_hint__", list, zero, set(), {"__iter__" : iden, "__next__" : stop}), ("__sizeof__", sys.getsizeof, zero, set(), {}), - ("__instancecheck__", do_isinstance, return_true, set(), {}), ("__missing__", do_dict_missing, some_number, set(("__class__",)), {}), - ("__subclasscheck__", do_issubclass, return_true, - set(("__bases__",)), {}), ("__enter__", run_context, iden, set(), {"__exit__" : swallow}), ("__exit__", run_context, swallow, set(), {"__enter__" : iden}), ("__complex__", complex, complex_num, set(), {}), diff --git a/Objects/abstract.c b/Objects/abstract.c index f2c7de3d1ef..290ba1b801d 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -2691,9 +2691,6 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls return ok; } - else if (_PyErr_Occurred(tstate)) { - return -1; - } /* cls has no __instancecheck__() method */ return object_isinstance(inst, cls); @@ -2779,9 +2776,6 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) } return ok; } - else if (_PyErr_Occurred(tstate)) { - return -1; - } /* Can be reached when infinite recursion happens. */ return recursive_issubclass(derived, cls); diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 8b526f43f1e..2c4c8f5eb73 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -654,6 +654,8 @@ static const char* const attr_exceptions[] = { "__parameters__", "__typing_unpacked_tuple_args__", "__mro_entries__", + "__instancecheck__", + "__subclasscheck__", "__reduce_ex__", // needed so we don't look up object.__reduce_ex__ "__reduce__", NULL,