aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorErik Welch <erik.n.welch@gmail.com>2021-06-22 16:00:51 -0500
committerGitHub <noreply@github.com>2021-06-22 14:00:51 -0700
commit6af4e6b266cb19d646ad7e4051fc7974c3096d23 (patch)
tree7dd835f4d8388c0d5e496268c167166512184159
parenta6b47de07a304eaa37a1c5554ed00a3ec91f8407 (diff)
downloadcpython-6af4e6b266cb19d646ad7e4051fc7974c3096d23.tar.gz
cpython-6af4e6b266cb19d646ad7e4051fc7974c3096d23.zip
bpo-43918: document signature and default argument of `anext` builtin (#25551)
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2021-04-23-03-46-45.bpo-43918.nNDY3S.rst1
-rw-r--r--Python/bltinmodule.c7
-rw-r--r--Python/clinic/bltinmodule.c.h7
3 files changed, 11 insertions, 4 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-04-23-03-46-45.bpo-43918.nNDY3S.rst b/Misc/NEWS.d/next/Core and Builtins/2021-04-23-03-46-45.bpo-43918.nNDY3S.rst
new file mode 100644
index 00000000000..f2f33f02abb
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-04-23-03-46-45.bpo-43918.nNDY3S.rst
@@ -0,0 +1 @@
+Document the signature and ``default`` argument in the docstring of the new ``anext`` builtin. \ No newline at end of file
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 66a74cbdef6..66c5fba275d 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1631,13 +1631,16 @@ anext as builtin_anext
default: object = NULL
/
-Return the next item from the async iterator.
+async anext(aiterator[, default])
+
+Return the next item from the async iterator. If default is given and the async
+iterator is exhausted, it is returned instead of raising StopAsyncIteration.
[clinic start generated code]*/
static PyObject *
builtin_anext_impl(PyObject *module, PyObject *aiterator,
PyObject *default_value)
-/*[clinic end generated code: output=f02c060c163a81fa input=699d11f4e38eca24]*/
+/*[clinic end generated code: output=f02c060c163a81fa input=8f63f4f78590bb4c]*/
{
PyTypeObject *t;
PyObject *awaitable;
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index 545f5b53f6e..4ea58761cf9 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -543,7 +543,10 @@ PyDoc_STRVAR(builtin_anext__doc__,
"anext($module, aiterator, default=<unrepresentable>, /)\n"
"--\n"
"\n"
-"Return the next item from the async iterator.");
+"async anext(aiterator[, default])\n"
+"\n"
+"Return the next item from the async iterator. If default is given and the async\n"
+"iterator is exhausted, it is returned instead of raising StopAsyncIteration.");
#define BUILTIN_ANEXT_METHODDEF \
{"anext", (PyCFunction)(void(*)(void))builtin_anext, METH_FASTCALL, builtin_anext__doc__},
@@ -874,4 +877,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=da9ae459e9233259 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e1d8057298b5de61 input=a9049054013a1b77]*/