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

Mark Shannon report at bugs.python.org
Thu Sep 17 06:03:19 EDT 2020


Mark Shannon <mark at hotpy.org> added the comment:

I agree with Serhiy, that `PyGen_` is a bad prefix.

Unless a function takes generator objects and *only* generators objects, then it shouldn't have a `PyGen` prefix.

The API function is the C equivalent of obj.send(val).
The first parameter is an object.

Coroutines do not inherit from generators.
That the the C implementations are so coupled is an unfortunate historical accident, and may well be changed.

Regardless of how this is implemented internally, any API function's signature should reflect the equivalent Python code.
And please use an enum, not an int, as the return value. It's a huge boon for readability.

I would suggest:
`PySendResult PyIter_Send(PyObject *obj, PyObject *arg, PyObject **result);`

----------

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


More information about the Python-bugs-list mailing list