[issue43751] await anext() returns None when default is given

Dennis Sweeney report at bugs.python.org
Tue Apr 6 15:03:26 EDT 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

I can open a PR this evening, but I think this is close to the issue: PyIter_Next() already silences StopIteration, so checking for it afterward fails.

diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index f0c6b79917..95f4659dc9 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -316,7 +316,7 @@ anextawaitable_traverse(anextawaitableobject *obj, visitproc visit, void *arg)
 static PyObject *
 anextawaitable_iternext(anextawaitableobject *obj)
 {
-    PyObject *result = PyIter_Next(obj->wrapped);
+    PyObject *result = (*Py_TYPE(obj->wrapped)->tp_iternext)(obj->wrapped);
     if (result != NULL) {
         return result;
     }

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43751>
_______________________________________


More information about the Python-bugs-list mailing list