diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-18 02:31:42 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-18 02:31:42 +0200 |
commit | c9dee2f3f478bed1bdb6b88e7c6c9c44643eea41 (patch) | |
tree | 7db01bdad7de7aad495d598a60809d4dc679e237 | |
parent | e9f16556470a89b044830abb8213083cd9328240 (diff) | |
download | trollius-c9dee2f3f478bed1bdb6b88e7c6c9c44643eea41.tar.gz |
On Python 2, define the __wrapped__ attribute, so _get_function_source() can
retrieve the source of the wrapped function (instead of the source of the
wrapper).
-rw-r--r-- | trollius/coroutines.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/trollius/coroutines.py b/trollius/coroutines.py index 9fb6438..b2bf8c8 100644 --- a/trollius/coroutines.py +++ b/trollius/coroutines.py @@ -129,6 +129,8 @@ def coroutine(func): if isinstance(res, futures.Future) or inspect.isgenerator(res): res = yield From(res) raise Return(res) + if not compat.PY3: + coro.__wrapped__ = func if not _DEBUG: wrapper = coro @@ -141,6 +143,8 @@ def coroutine(func): w.__qualname__ = func.__qualname__ w.__doc__ = func.__doc__ return w + if not compat.PY3: + wrapper.__wrapped__ = func wrapper._is_coroutine = True # For iscoroutinefunction(). return wrapper |