summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 01:24:48 (GMT)
committerGitHub <noreply@github.com>2020-02-07 01:24:48 (GMT)
commita102ed7d2f0e7e05438f14d5fb72ca0358602249 (patch)
treea5a3aca7a251c82d7b35c130cc913d6009baa18a /Include
parent38aaaaac805fa30870e2d093e52a900dddde3b34 (diff)
downloadcpython-a102ed7d2f0e7e05438f14d5fb72ca0358602249.zip
cpython-a102ed7d2f0e7e05438f14d5fb72ca0358602249.tar.gz
cpython-a102ed7d2f0e7e05438f14d5fb72ca0358602249.tar.bz2
bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)
Replace direct access to PyObject.ob_type with Py_TYPE().
Diffstat (limited to 'Include')
-rw-r--r--Include/classobject.h4
-rw-r--r--Include/cpython/abstract.h12
-rw-r--r--Include/pyerrors.h4
3 files changed, 10 insertions, 10 deletions
diff --git a/Include/classobject.h b/Include/classobject.h
index 840431a..8742720 100644
--- a/Include/classobject.h
+++ b/Include/classobject.h
@@ -19,7 +19,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyMethod_Type;
-#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
+#define PyMethod_Check(op) (Py_TYPE(op)== &PyMethod_Type)
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
@@ -40,7 +40,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
-#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
+#define PyInstanceMethod_Check(op) (Py_TYPE(op) == &PyInstanceMethod_Type)
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
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 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
/* 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 @@ PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
/* ==== 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 ================================================ */
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 5125a51..3fd133c 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -54,11 +54,11 @@ PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
#define PyExceptionInstance_Check(x) \
- PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)
+ PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)
PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);
-#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
+#define PyExceptionInstance_Class(x) ((PyObject*)Py_TYPE(x))
/* Predefined exceptions */