summaryrefslogtreecommitdiff
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-24 22:57:14 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-06-24 22:57:14 +0200
commit6395e5e83bd7393f9fcc6e8a4febdb0dfdb68e40 (patch)
tree46bfac11c97cfd52a29ba1b2082e63448099dcec /Lib/asyncio
parent61e6b3f56d42fe56f130dc9588a4bc92ba567807 (diff)
downloadcpython-6395e5e83bd7393f9fcc6e8a4febdb0dfdb68e40.tar.gz
asyncio: repr(Task) now also contains the line number even if the coroutine is
done: use the first line number of the code object instead of the current line number of the generator frame. The name of the coroutine is not enough because many coroutines may have the same name. It's a common case in asyncio tests for example.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/tasks.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index f5c10c8665..3b41a21c8a 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -208,9 +208,11 @@ class Task(futures.Future):
if iscoroutine(coro):
filename = coro.gi_code.co_filename
if coro.gi_frame is not None:
- text += ' at %s:%s' % (filename, coro.gi_frame.f_lineno)
+ lineno = coro.gi_frame.f_lineno
+ text += ' at %s:%s' % (filename, lineno)
else:
- text += ' done at %s' % filename
+ lineno = coro.gi_code.co_firstlineno
+ text += ' done at %s:%s' % (filename, lineno)
res = res[:i] + '(<{}>)'.format(text) + res[i:]
return res