From 989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Mon, 28 May 2018 16:27:34 -0400 Subject: bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161) --- Lib/asyncio/format_helpers.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Lib/asyncio/format_helpers.py') diff --git a/Lib/asyncio/format_helpers.py b/Lib/asyncio/format_helpers.py index 39cfcee0c1..27d11fd4fa 100644 --- a/Lib/asyncio/format_helpers.py +++ b/Lib/asyncio/format_helpers.py @@ -1,6 +1,7 @@ import functools import inspect import reprlib +import sys import traceback from . import constants @@ -45,10 +46,10 @@ def _format_callback(func, args, kwargs, suffix=''): suffix = _format_args_and_kwargs(args, kwargs) + suffix return _format_callback(func.func, func.args, func.keywords, suffix) - if hasattr(func, '__qualname__'): - func_repr = getattr(func, '__qualname__') - elif hasattr(func, '__name__'): - func_repr = getattr(func, '__name__') + if hasattr(func, '__qualname__') and func.__qualname__: + func_repr = func.__qualname__ + elif hasattr(func, '__name__') and func.__name__: + func_repr = func.__name__ else: func_repr = repr(func) -- cgit v1.2.1