Skip to content

Commit 307b9d0

Browse files
authored
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.
1 parent a15e260 commit 307b9d0

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

Include/cpython/abstract.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,6 @@ PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
335335
(Py_TYPE(obj)->tp_iternext != NULL && \
336336
Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented)
337337

338-
/* === Number Protocol ================================================== */
339-
340-
#define PyIndex_Check(obj) \
341-
(Py_TYPE(obj)->tp_as_number != NULL && \
342-
Py_TYPE(obj)->tp_as_number->nb_index != NULL)
343-
344338
/* === Sequence protocol ================================================ */
345339

346340
/* Assume tp_as_sequence and sq_item exist and that 'i' does not
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Always declare :c:func:`PyIndex_Check` as an opaque function to hide
2+
implementation details: remove ``PyIndex_Check()`` macro. The macro accessed
3+
directly the :c:member:`PyTypeObject.tp_as_number` member.

Objects/abstract.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,6 @@ PyNumber_Absolute(PyObject *o)
13091309
}
13101310

13111311

1312-
#undef PyIndex_Check
1313-
13141312
int
13151313
PyIndex_Check(PyObject *obj)
13161314
{

0 commit comments

Comments
 (0)