summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-15 20:01:35 (GMT)
committerYury Selivanov <yury@magic.io>2016-09-15 20:01:35 (GMT)
commit62b81c33d146d4f5b36589a93736b57d604cf260 (patch)
treeab7306eb66f88af858a181162a6d72201e0dce21 /Lib/asyncio
parent1b984ffd44f036cf5c0ce1933c0fb9ba6e94948a (diff)
parent45dccdad93fbfa5c2b90a697b47d5286115827aa (diff)
downloadcpython-62b81c33d146d4f5b36589a93736b57d604cf260.zip
cpython-62b81c33d146d4f5b36589a93736b57d604cf260.tar.gz
cpython-62b81c33d146d4f5b36589a93736b57d604cf260.tar.bz2
Merge 3.5 (issue #26654)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/coroutines.py2
-rw-r--r--Lib/asyncio/events.py27
2 files changed, 15 insertions, 14 deletions
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py
index 72ffb44..e013d64 100644
--- a/Lib/asyncio/coroutines.py
+++ b/Lib/asyncio/coroutines.py
@@ -271,7 +271,7 @@ def _format_coroutine(coro):
func = coro
if coro_name is None:
- coro_name = events._format_callback(func, ())
+ coro_name = events._format_callback(func, (), {})
try:
coro_code = coro.gi_code
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index cc9a986..3a33646 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -35,23 +35,25 @@ def _get_function_source(func):
return None
-def _format_args(args):
- """Format function arguments.
+def _format_args_and_kwargs(args, kwargs):
+ """Format function arguments and keyword arguments.
Special case for a single parameter: ('hello',) is formatted as ('hello').
"""
# use reprlib to limit the length of the output
- args_repr = reprlib.repr(args)
- if len(args) == 1 and args_repr.endswith(',)'):
- args_repr = args_repr[:-2] + ')'
- return args_repr
+ items = []
+ if args:
+ items.extend(reprlib.repr(arg) for arg in args)
+ if kwargs:
+ items.extend('{}={}'.format(k, reprlib.repr(v))
+ for k, v in kwargs.items())
+ return '(' + ', '.join(items) + ')'
-def _format_callback(func, args, suffix=''):
+def _format_callback(func, args, kwargs, suffix=''):
if isinstance(func, functools.partial):
- if args is not None:
- suffix = _format_args(args) + suffix
- return _format_callback(func.func, func.args, 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__')
@@ -60,14 +62,13 @@ def _format_callback(func, args, suffix=''):
else:
func_repr = repr(func)
- if args is not None:
- func_repr += _format_args(args)
+ func_repr += _format_args_and_kwargs(args, kwargs)
if suffix:
func_repr += suffix
return func_repr
def _format_callback_source(func, args):
- func_repr = _format_callback(func, args)
+ func_repr = _format_callback(func, args, None)
source = _get_function_source(func)
if source:
func_repr += ' at %s:%s' % source