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

Serhiy Storchaka report at bugs.python.org
Wed Sep 16 13:01:40 EDT 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

As for returned value, I propose to return -1 in case of error, 1 for yielded value and 0 for returned value (i.e. define PYGEN_RETURN = 0, PYGEN_YIELD = 1 and PYGEN_ERROR = -1, but without exposing public names).

It would be uniform with other C API: many functions return -1 on error (if they return int and can fail), and PyDict_Next() and _PySet_NextEntry() return 1 for every yielded item, and 0 if the iteration has been finished.

----------

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


More information about the Python-bugs-list mailing list