Open diefans opened 7 years ago
This is a bug in CoroWrapper
.
I am wondering, if the TypeError for a coroutine returned by await() enforced by https://www.python.org/dev/peps/pep-0492/#await-expression is really necessary.
It is necessary. __await__
requires an iterator and coroutines don't implement iterator protocol (because casting a coroutine in, let's say, tuple, doesn't make any sense).
To properly fix this, we'll need to split CoroWrapper
class in two -- one for generator-based coroutines, and one for async/await coroutines. This is something that can break a lot of things, so let's wait until 3.7.
My python version is 3.5.2
The following example illustrates the problem:
This behaviour was indeed surprising when I begun to work and experiment with asyncio, where most of the time I enabled debug, but in unit testing then disabled it...
I am wondering, if the TypeError for a coroutine returned by await() enforced by https://www.python.org/dev/peps/pep-0492/#await-expression is really necessary. Btw to use await syntax in await I always return the result of the await method of an inner coroutine, e.g.: