summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/format_helpers.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-05-28 20:27:34 (GMT)
committerGitHub <noreply@github.com>2018-05-28 20:27:34 (GMT)
commit989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006 (patch)
treedaf171ce1cdd2908624b75c80a85466e72fa46f6 /Lib/asyncio/format_helpers.py
parent8267ea2e84d355f00654dec3ad782fc7b1f680f1 (diff)
downloadcpython-989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006.zip
cpython-989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006.tar.gz
cpython-989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006.tar.bz2
bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161)
Diffstat (limited to 'Lib/asyncio/format_helpers.py')
-rw-r--r--Lib/asyncio/format_helpers.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/asyncio/format_helpers.py b/Lib/asyncio/format_helpers.py
index 39cfcee..27d11fd 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)