
April 23, 2015
6:39 p.m.
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