Skip to content

bpo-31861: Complete the C-API docs for PyObject_GetAiter and PyAiter_Check #25004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2021
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
6 changes: 6 additions & 0 deletions Doc/c-api/iter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ There are two functions specifically for working with iterators.
Return non-zero if the object *o* supports the iterator protocol, and ``0``
otherwise. This function always succeeds.

.. c:function:: int PyAiter_Check(PyObject *o)

Returns non-zero if the object 'obj' provides :class:`AsyncIterator`
protocols, and ``0`` otherwise. This function always succeeds.

.. versionadded:: 3.10

.. c:function:: PyObject* PyIter_Next(PyObject *o)

Expand Down
11 changes: 11 additions & 0 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,14 @@ Object Protocol
iterator for the object argument, or the object itself if the object is already
an iterator. Raises :exc:`TypeError` and returns ``NULL`` if the object cannot be
iterated.


.. c:function:: PyObject* PyObject_GetAiter(PyObject *o)

This is the equivalent to the Python expression ``aiter(o)``. Takes an
:class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it.
This is typically a new iterator but if the argument is an
:class:`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and
returns ``NULL`` if the object cannot be iterated.

.. versionadded:: 3.10
6 changes: 6 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,9 @@ PyInterpreterState_New:PyInterpreterState*:::
PyIter_Check:int:::
PyIter_Check:PyObject*:o:0:

PyAiter_Check:int:::
PyAiter_Check:PyObject*:o:0:

PyIter_Next:PyObject*::+1:
PyIter_Next:PyObject*:o:0:

Expand Down Expand Up @@ -1679,6 +1682,9 @@ PyObject_GetItem:PyObject*:key:0:
PyObject_GetIter:PyObject*::+1:
PyObject_GetIter:PyObject*:o:0:

PyObject_GetAiter:PyObject*::+1:
PyObject_GetAiter:PyObject*:o:0:

PyObject_HasAttr:int:::
PyObject_HasAttr:PyObject*:o:0:
PyObject_HasAttr:PyObject*:attr_name:0:
Expand Down
2 changes: 2 additions & 0 deletions Doc/data/stable_abi.dat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# File generated by 'make regen-limited-abi'
# This is NOT an authoritative list of stable ABI symbols
PyAiter_Check
PyArg_Parse
PyArg_ParseTuple
PyArg_ParseTupleAndKeywords
Expand Down Expand Up @@ -465,6 +466,7 @@ PyObject_GenericGetAttr
PyObject_GenericGetDict
PyObject_GenericSetAttr
PyObject_GenericSetDict
PyObject_GetAiter
PyObject_GetAttr
PyObject_GetAttrString
PyObject_GetItem
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ are always available. They are listed here in alphabetical order.

Note: Unlike :func:`iter`, :func:`aiter` has no 2-argument variant.

.. versionadded:: 3.10

.. function:: all(iterable)

Expand All @@ -97,6 +98,7 @@ are always available. They are listed here in alphabetical order.
iterator. If *default* is given, it is returned if the iterator is exhausted,
otherwise :exc:`StopAsyncIteration` is raised.

.. versionadded:: 3.10

.. function:: any(iterable)

Expand Down