bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)
Replace direct access to PyObject.ob_type with Py_TYPE().
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index 4bd7b1a..76eaedf 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -246,8 +246,8 @@
/* Return 1 if the getbuffer function is available, otherwise return 0. */
#define PyObject_CheckBuffer(obj) \
- (((obj)->ob_type->tp_as_buffer != NULL) && \
- ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
+ ((Py_TYPE(obj)->tp_as_buffer != NULL) && \
+ (Py_TYPE(obj)->tp_as_buffer->bf_getbuffer != NULL))
/* This is a C-API version of the getbuffer function call. It checks
to make sure object has the required function pointer and issues the
@@ -315,14 +315,14 @@
/* ==== Iterators ================================================ */
#define PyIter_Check(obj) \
- ((obj)->ob_type->tp_iternext != NULL && \
- (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
+ (Py_TYPE(obj)->tp_iternext != NULL && \
+ Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented)
/* === Number Protocol ================================================== */
#define PyIndex_Check(obj) \
- ((obj)->ob_type->tp_as_number != NULL && \
- (obj)->ob_type->tp_as_number->nb_index != NULL)
+ (Py_TYPE(obj)->tp_as_number != NULL && \
+ Py_TYPE(obj)->tp_as_number->nb_index != NULL)
/* === Sequence protocol ================================================ */