[issue29909] types.coroutine monkey patches original function

R. David Murray report at bugs.python.org
Sun Mar 26 11:08:21 EDT 2017


R. David Murray added the comment:

Yes, that looks wrong to me.  IMO it should be returning a new function object, not updating the __code__ of the existing object.  I couldn't figure when that is actually triggered, though.  

There are also some other oddnesses, given the definition of 'coroutine' in the 'types' module docs.  type(x) returns 'coroutine' only when you actually *call* the async def function.  I think that's correct, but the docs need rewording.  However, if I call coroutine on the equivalent non-async-def generator, types(x()) returns generator, not coroutine.  So it doesn't seem to be doing what it says on the label, at least not in all cases.

----------
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29909>
_______________________________________


More information about the Python-bugs-list mailing list