Skip to content

Commit d969202

Browse files
authored
bpo-31861: Complete the C-API docs for PyObject_GetAiter and PyAiter_Check (GH-25004)
1 parent a81fca6 commit d969202

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

Doc/c-api/iter.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ There are two functions specifically for working with iterators.
1212
Return non-zero if the object *o* supports the iterator protocol, and ``0``
1313
otherwise. This function always succeeds.
1414
15+
.. c:function:: int PyAiter_Check(PyObject *o)
16+
17+
Returns non-zero if the object 'obj' provides :class:`AsyncIterator`
18+
protocols, and ``0`` otherwise. This function always succeeds.
19+
20+
.. versionadded:: 3.10
1521
1622
.. c:function:: PyObject* PyIter_Next(PyObject *o)
1723

Doc/c-api/object.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,14 @@ Object Protocol
356356
iterator for the object argument, or the object itself if the object is already
357357
an iterator. Raises :exc:`TypeError` and returns ``NULL`` if the object cannot be
358358
iterated.
359+
360+
361+
.. c:function:: PyObject* PyObject_GetAiter(PyObject *o)
362+
363+
This is the equivalent to the Python expression ``aiter(o)``. Takes an
364+
:class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it.
365+
This is typically a new iterator but if the argument is an
366+
:class:`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and
367+
returns ``NULL`` if the object cannot be iterated.
368+
369+
.. versionadded:: 3.10

Doc/data/refcounts.dat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,9 @@ PyInterpreterState_New:PyInterpreterState*:::
10731073
PyIter_Check:int:::
10741074
PyIter_Check:PyObject*:o:0:
10751075

1076+
PyAiter_Check:int:::
1077+
PyAiter_Check:PyObject*:o:0:
1078+
10761079
PyIter_Next:PyObject*::+1:
10771080
PyIter_Next:PyObject*:o:0:
10781081

@@ -1679,6 +1682,9 @@ PyObject_GetItem:PyObject*:key:0:
16791682
PyObject_GetIter:PyObject*::+1:
16801683
PyObject_GetIter:PyObject*:o:0:
16811684

1685+
PyObject_GetAiter:PyObject*::+1:
1686+
PyObject_GetAiter:PyObject*:o:0:
1687+
16821688
PyObject_HasAttr:int:::
16831689
PyObject_HasAttr:PyObject*:o:0:
16841690
PyObject_HasAttr:PyObject*:attr_name:0:

Doc/data/stable_abi.dat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# File generated by 'make regen-limited-abi'
22
# This is NOT an authoritative list of stable ABI symbols
3+
PyAiter_Check
34
PyArg_Parse
45
PyArg_ParseTuple
56
PyArg_ParseTupleAndKeywords
@@ -465,6 +466,7 @@ PyObject_GenericGetAttr
465466
PyObject_GenericGetDict
466467
PyObject_GenericSetAttr
467468
PyObject_GenericSetDict
469+
PyObject_GetAiter
468470
PyObject_GetAttr
469471
PyObject_GetAttrString
470472
PyObject_GetItem

Doc/library/functions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ are always available. They are listed here in alphabetical order.
7171

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

74+
.. versionadded:: 3.10
7475

7576
.. function:: all(iterable)
7677

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

101+
.. versionadded:: 3.10
100102

101103
.. function:: any(iterable)
102104

0 commit comments

Comments
 (0)