[New-bugs-announce] [issue25648] asyncio.coroutine fails if asyncio debug mode is enabled and wrapped function don't have "__name__" attribute
report at bugs.python.org
Tue Nov 17 07:47:20 EST 2015
New submission from Vladimir Rutsky:
In Python 3.4.3 with enabled asyncio debug a function is
wrapped using the following code in @asyncio.coroutine:
def wrapper(*args, **kwds):
w = CoroWrapper(coro(*args, **kwds), func)
w.__name__ = func.__name__
if hasattr(func, '__qualname__'):
w.__qualname__ = func.__qualname__
w.__doc__ = func.__doc__
The unconditional access to "__name__" and "__doc__" attributes may fail in some circumstances.
As this case looks strange and unrealistic I met it in a real
application that used mocking in tests. The code there was something like the following:
return "f result"
mocked_f = Mock(wraps=f)
coro_func = asyncio.coroutine(mocked_f)
Here is complete example:
This issue is fixed in 95964:957478e95b26 changeset during adding support of async/await syntax, so it is not reproduced in Python 3.5 or 3.4 head, but still reproducible in latest released version of Python 3.4 branch: 3.4.3.
So until 3.4.4 is released this issue still may be considered as not fixed.
nosy: gvanrossum, haypo, vrutsky, yselivanov
title: asyncio.coroutine fails if asyncio debug mode is enabled and wrapped function don't have "__name__" attribute
versions: Python 3.4
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce