summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/format_helpers.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-05-28 22:31:07 (GMT)
committerYury Selivanov <yury@magic.io>2018-05-28 22:31:07 (GMT)
commit075c662086859f864aa1179f57367aa470ee6335 (patch)
treed8d20649b54980e623a4b02470255b582644d68f /Lib/asyncio/format_helpers.py
parent4b828467a3fcec0c1947e8326f67b8db12a4f303 (diff)
downloadcpython-075c662086859f864aa1179f57367aa470ee6335.zip
cpython-075c662086859f864aa1179f57367aa470ee6335.tar.gz
cpython-075c662086859f864aa1179f57367aa470ee6335.tar.bz2
bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161) (GH-7173)
(cherry picked from commit 989b9e0e6d7dd2fa911f9bfd4744e7f3a82d6006) Co-authored-by: Yury Selivanov <yury@magic.io>
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)