.. c:function:: int PyIter_Check(PyObject *o)
- Return true if the object *o* supports the iterator protocol. This
- function always succeeds.
+ Return non-zero if the object *o* supports the iterator protocol, and ``0``
+ otherwise. This function always succeeds.
.. c:function:: PyObject* PyIter_Next(PyObject *o)
returns itself. */
PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
-/* Returns 1 if the object 'obj' provides iterator protocols, and 0 otherwise.
+/* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise.
This function always succeeds. */
PyAPI_FUNC(int) PyIter_Check(PyObject *);
/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
-/* ==== Iterators ================================================ */
-
-#define PyIter_Check(obj) \
- (Py_TYPE(obj)->tp_iternext != NULL && \
- Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented)
-
/* === Sequence protocol ================================================ */
/* Assume tp_as_sequence and sq_item exist and that 'i' does not
--- /dev/null
+:c:func:`PyIter_Check` is now always declared as a function, in order to hide implementation
+details. The macro accessed :c:member:`PyTypeObject.tp_iternext` directly.
+Patch by Erlend E. Aasland.
}
}
-#undef PyIter_Check
-
-int PyIter_Check(PyObject *obj)
+int
+PyIter_Check(PyObject *obj)
{
- return Py_TYPE(obj)->tp_iternext != NULL &&
- Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented;
+ PyTypeObject *tp = Py_TYPE(obj);
+ return (tp->tp_iternext != NULL &&
+ tp->tp_iternext != &_PyObject_NextNotImplemented);
}
/* Return next item.