summaryrefslogtreecommitdiff
path: root/Include/object.h
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-11 01:57:16 -0700
committerGitHub <noreply@github.com>2021-06-11 01:57:16 -0700
commite6d28a1a6ad22125fc3a6df2d611d79aa8d6f67e (patch)
tree77121afd3b740a5b77072c9df6d4a01f9ea9229c /Include/object.h
parentd7930fb720b5e9db2076b116dffcd52b6ca71438 (diff)
downloadcpython-git-e6d28a1a6ad22125fc3a6df2d611d79aa8d6f67e.tar.gz
bpo-44378: Fix a compiler warning in Py_IS_TYPE() (GH-26644)
Py_IS_TYPE() no longer uses Py_TYPE() to avoid a compiler warning: no longer cast "const PyObject*" to "PyObject*". (cherry picked from commit 304dfec8d3c0763734ea8b5fa2af1d9e1ce69ffa) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Include/object.h b/Include/object.h
index 4c06999857..109f535249 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -141,7 +141,9 @@ static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) {
static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
- return Py_TYPE(ob) == type;
+ // bpo-44378: Don't use Py_TYPE() since Py_TYPE() requires a non-const
+ // object.
+ return ob->ob_type == type;
}
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST_CONST(ob), type)