summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-17 23:14:59 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-17 23:14:59 (GMT)
commit8d3e02ef5a452b59fc909bf45d1d18bfd916c596 (patch)
tree7c03d264b990109a99a92866b09b8c98409ff9fd /Lib/asyncio
parent66dc6b0f5355857ea73f59e6eb2066bf6604d322 (diff)
downloadcpython-8d3e02ef5a452b59fc909bf45d1d18bfd916c596.zip
cpython-8d3e02ef5a452b59fc909bf45d1d18bfd916c596.tar.gz
cpython-8d3e02ef5a452b59fc909bf45d1d18bfd916c596.tar.bz2
asyncio: Set __qualname__ attribute of CoroWrapper in @coroutine decorator on
Python 3.5 - Drop __slots__ optimization of CoroWrapper to be able to set the __qualname__ attribute. - Add tests on __name__, __qualname__ and __module__ of a coroutine function and coroutine object. - Fix test_tasks when run in debug mode (PYTHONASYNCIODEBUG env var set) on Python 3.3 or 3.4
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/tasks.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 281bf60..eaf93f8 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -32,12 +32,12 @@ from .log import logger
_DEBUG = (not sys.flags.ignore_environment
and bool(os.environ.get('PYTHONASYNCIODEBUG')))
+_PY35 = (sys.version_info >= (3, 5))
+
class CoroWrapper:
# Wrapper for coroutine in _DEBUG mode.
- __slots__ = ['gen', 'func', '__name__', '__doc__', '__weakref__']
-
def __init__(self, gen, func):
assert inspect.isgenerator(gen), gen
self.gen = gen
@@ -111,8 +111,10 @@ def coroutine(func):
@functools.wraps(func)
def wrapper(*args, **kwds):
w = CoroWrapper(coro(*args, **kwds), func)
- w.__name__ = coro.__name__
- w.__doc__ = coro.__doc__
+ w.__name__ = func.__name__
+ if _PY35:
+ w.__qualname__ = func.__qualname__
+ w.__doc__ = func.__doc__
return w
wrapper._is_coroutine = True # For iscoroutinefunction().