summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorYury Selivanov <yury@edgedb.com>2021-09-07 10:52:30 (GMT)
committerGitHub <noreply@github.com>2021-09-07 10:52:30 (GMT)
commit2c3474a637949aa6f2f7e15f9764c2dfc49cdba1 (patch)
treed19d7d6dbdeb410d2413711b9610bc4344fd12ef /Objects/abstract.c
parenteb254b43d2916ef8c0e9ca815fe047411d848aae (diff)
downloadcpython-2c3474a637949aa6f2f7e15f9764c2dfc49cdba1.zip
cpython-2c3474a637949aa6f2f7e15f9764c2dfc49cdba1.tar.gz
cpython-2c3474a637949aa6f2f7e15f9764c2dfc49cdba1.tar.bz2
bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194)
Fix PyAiter_Check to only check for the `__anext__` presense (not for `__aiter__`). Rename `PyAiter_Check()` to `PyAIter_Check()`, `PyObject_GetAiter()` -> `PyObject_GetAIter()`. Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 8ad1910..33eb857 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2816,18 +2816,18 @@ PyObject_GetIter(PyObject *o)
}
PyObject *
-PyObject_GetAiter(PyObject *o) {
+PyObject_GetAIter(PyObject *o) {
PyTypeObject *t = Py_TYPE(o);
unaryfunc f;
if (t->tp_as_async == NULL || t->tp_as_async->am_aiter == NULL) {
- return type_error("'%.200s' object is not an AsyncIterable", o);
+ return type_error("'%.200s' object is not an async iterable", o);
}
f = t->tp_as_async->am_aiter;
PyObject *it = (*f)(o);
- if (it != NULL && !PyAiter_Check(it)) {
+ if (it != NULL && !PyAIter_Check(it)) {
PyErr_Format(PyExc_TypeError,
- "aiter() returned non-AsyncIterator of type '%.100s'",
+ "aiter() returned not an async iterator of type '%.100s'",
Py_TYPE(it)->tp_name);
Py_DECREF(it);
it = NULL;
@@ -2844,12 +2844,10 @@ PyIter_Check(PyObject *obj)
}
int
-PyAiter_Check(PyObject *obj)
+PyAIter_Check(PyObject *obj)
{
PyTypeObject *tp = Py_TYPE(obj);
return (tp->tp_as_async != NULL &&
- tp->tp_as_async->am_aiter != NULL &&
- tp->tp_as_async->am_aiter != &_PyObject_NextNotImplemented &&
tp->tp_as_async->am_anext != NULL &&
tp->tp_as_async->am_anext != &_PyObject_NextNotImplemented);
}