summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-02-15 16:19:24 (GMT)
committerGitHub <noreply@github.com>2021-02-15 16:19:24 (GMT)
commit4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d (patch)
tree3d35304e122385f6f9a3e79f123a51035dfc8b77 /Include
parentfcbe0cb04d35189401c0c880ebfb4311e952d776 (diff)
downloadcpython-4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d.zip
cpython-4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d.tar.gz
cpython-4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d.tar.bz2
bpo-43181: Convert PyObject_TypeCheck to static inline function (GH-24533)
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h
index 8d00394..0870e4c 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -235,8 +235,11 @@ PyAPI_FUNC(void *) PyType_GetModuleState(struct _typeobject *);
/* 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' */