From 6cc495e9e2db8de0b8b7d95323d3a1514844b1b4 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 8 Nov 2016 19:16:01 -0500 Subject: asyncio: Fix _format_coroutine for coroutine-like objects w/o __name__ Some built-in coroutine-like objects might not have __name__ or __qualname__. A good example of such are 'asend', 'aclose' and 'athrow' coroutine methods of asynchronous generators. --- Lib/asyncio/coroutines.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Lib/asyncio/coroutines.py') diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index 1db7030205..f46197dea6 100644 --- a/Lib/asyncio/coroutines.py +++ b/Lib/asyncio/coroutines.py @@ -262,8 +262,12 @@ def _format_coroutine(coro): assert iscoroutine(coro) if not hasattr(coro, 'cr_code') and not hasattr(coro, 'gi_code'): - # Most likely a Cython coroutine. - coro_name = getattr(coro, '__qualname__', coro.__name__) + # Most likely a built-in type or a Cython coroutine. + + # Built-in types might not have __qualname__ or __name__. + coro_name = getattr( + coro, '__qualname__', + getattr(coro, '__name__', type(coro).__name__)) coro_name = '{}()'.format(coro_name) running = False -- cgit v1.2.1