[issue29909] types.coroutine monkey patches original function
Eric Hopper
report at bugs.python.org
Sun Mar 26 04:59:57 EDT 2017
New submission from Eric Hopper:
The types.coroutine decorator for Python 3.6 (and I suspect for Python 3.6.1 as well) simply monkey patches the function it's passed and then returns it. This results in behavior that I found somewhat surprising.
def bar():
yield 5
foo = types.coroutine(bar)
foo is bar
And, so now both foo and bar are now awaitable. I wasn't really expecting this, and while it's minor, it also doesn't really seem like the right thing to do.
----------
components: asyncio
messages: 290518
nosy: Omnifarious, yselivanov
priority: normal
severity: normal
status: open
title: types.coroutine monkey patches original function
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29909>
_______________________________________
More information about the Python-bugs-list
mailing list