bpo-40170: Remove PyIndex_Check() macro (GH-19428)

Always declare PyIndex_Check() as an opaque function to hide
implementation details: remove PyIndex_Check() macro. The macro
accessed directly the PyTypeObject.tp_as_number member.
This commit is contained in:
Victor Stinner 2020-04-08 02:26:41 +02:00 committed by GitHub
parent a15e260b70
commit 307b9d0144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 8 deletions

View File

@ -335,12 +335,6 @@ PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
(Py_TYPE(obj)->tp_iternext != NULL && \ (Py_TYPE(obj)->tp_iternext != NULL && \
Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented) Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented)
/* === Number Protocol ================================================== */
#define PyIndex_Check(obj) \
(Py_TYPE(obj)->tp_as_number != NULL && \
Py_TYPE(obj)->tp_as_number->nb_index != NULL)
/* === Sequence protocol ================================================ */ /* === Sequence protocol ================================================ */
/* Assume tp_as_sequence and sq_item exist and that 'i' does not /* Assume tp_as_sequence and sq_item exist and that 'i' does not

View File

@ -0,0 +1,3 @@
Always declare :c:func:`PyIndex_Check` as an opaque function to hide
implementation details: remove ``PyIndex_Check()`` macro. The macro accessed
directly the :c:member:`PyTypeObject.tp_as_number` member.

View File

@ -1309,8 +1309,6 @@ PyNumber_Absolute(PyObject *o)
} }
#undef PyIndex_Check
int int
PyIndex_Check(PyObject *obj) PyIndex_Check(PyObject *obj)
{ {