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*".
This commit is contained in:
Victor Stinner 2021-06-11 10:35:36 +02:00 committed by GitHub
parent 3a7cccfd6c
commit 304dfec8d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -0,0 +1,3 @@
:c:func:`Py_IS_TYPE` no longer uses :c:func:`Py_TYPE` to avoid a compiler
warning: no longer cast ``const PyObject*`` to ``PyObject*``.
Patch by Victor Stinner.