bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)

diff --git a/Objects/classobject.c b/Objects/classobject.c
index 33afbcd..97f50fa 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -37,7 +37,7 @@
 method_vectorcall(PyObject *method, PyObject *const *args,
                   size_t nargsf, PyObject *kwnames)
 {
-    assert(Py_TYPE(method) == &PyMethod_Type);
+    assert(Py_IS_TYPE(method, &PyMethod_Type));
 
     PyThreadState *tstate = _PyThreadState_GET();
     PyObject *self = PyMethod_GET_SELF(method);