mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
14199f9392
commit
df29c4a83d
2 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue