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>
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)
--- /dev/null
+: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.