[Python-Dev] async/await in Python; v2

Yury Selivanov yselivanov.ml at gmail.com
Thu Apr 23 20:39:48 CEST 2015


On 2015-04-23 3:03 AM, Greg Ewing wrote:
> Yury Selivanov wrote:
>> - If it's an object with __await__, return iter(object.__await__())
>
> Is the iter() really needed? Couldn't the contract of
> __await__ be that it always returns an iterator?
>

I wrote it the wrong way. iter() isn't needed, you're right.
This is a quote from the ref implementation:

    if (!PyIter_Check(await_obj)) {
         PyErr_Format(PyExc_TypeError,
                      "__await__ must return an iterator, %.100s",
                      Py_TYPE(await_obj)->tp_name);


Yury


More information about the Python-Dev mailing list