[issue41756] Do not always use exceptions to return result from coroutine

Vladimir Matveev report at bugs.python.org
Thu Sep 17 17:21:23 EDT 2020


Vladimir Matveev <desco.by at gmail.com> added the comment:

so to summarize:

Proposed function signature:
```
PySendResult PyIter_Send(PyObject *obj, PyObject *arg, PyObject **result);
```

For generators/coroutines function will delegate to specialized implementation that does not raise StopIteration exception
For types that provide `tp_iternext` if arg is Py_None function call invoke `Py_TYPE(obj)->tp_iternext(obj)`
For all other cases function will try to call `send` method

Regarding of the case function will not raise StopIteration and will always return pair status/result.

Does it sound correct?

----------

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


More information about the Python-bugs-list mailing list