diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-12 16:39:26 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-12 16:39:26 (GMT) |
commit | 307bccc6ff6670c58f4c20421a29071ff710e6a3 (patch) | |
tree | e165b2e33505bcece03948112ca230af5d2d2688 /Lib/asyncio/test_utils.py | |
parent | f54432e2a16d445ed6fa142a9c5d8d23b11780b2 (diff) | |
download | cpython-307bccc6ff6670c58f4c20421a29071ff710e6a3.zip cpython-307bccc6ff6670c58f4c20421a29071ff710e6a3.tar.gz cpython-307bccc6ff6670c58f4c20421a29071ff710e6a3.tar.bz2 |
asyncio: Tulip issue 173: Enhance repr(Handle) and repr(Task)
repr(Handle) is shorter for function: "foo" instead of "<function foo at
0x...>". It now also includes the source of the callback, filename and line
number where it was defined, if available.
repr(Task) now also includes the current position in the code, filename and
line number, if available. If the coroutine (generator) is done, the line
number is omitted and "done" is added.
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r-- | Lib/asyncio/test_utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py index 9c3656a..1062bae 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -372,3 +372,10 @@ class MockPattern(str): """ def __eq__(self, other): return bool(re.search(str(self), other, re.S)) + + +def get_function_source(func): + source = events._get_function_source(func) + if source is None: + raise ValueError("unable to get the source of %r" % (func,)) + return source |