bpo-40170: Convert PyIter_Check macro to a function by erlend-aasland · Pull Request #24548 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/c-api/iter.rst
2 changes: 1 addition & 1 deletion Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj,
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 *);
Expand Down
6 changes: 0 additions & 6 deletions Include/cpython/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
/* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
: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.
10 changes: 5 additions & 5 deletions Objects/abstract.c