.. c:function:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
- Return true if the object *o* is of type *type* or a subtype of *type*. Both
- parameters must be non-``NULL``.
+ Return non-zero if the object *o* is of type *type* or a subtype of *type*, and
+ ``0`` otherwise. Both parameters must be non-``NULL``.
.. c:function:: Py_ssize_t PyObject_Size(PyObject *o)
/* Generic type check */
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
-#define PyObject_TypeCheck(ob, tp) \
- (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
+
+static inline int _PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
+ return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
+}
+#define PyObject_TypeCheck(ob, type) _PyObject_TypeCheck(_PyObject_CAST(ob), type)
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */