diff options
| author | Guido van Rossum <guido@python.org> | 2015-05-03 01:45:51 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2015-05-03 01:45:51 (GMT) |
| commit | 97bd4b0cd9dec026bfaa66f492f1ea3c45abb1b1 (patch) | |
| tree | e616def9aa86e826e57381597a6039a154357798 /Lib/asyncio/events.py | |
| parent | 32439d6eb63f1ea31aed1e45459f0f50f965ef51 (diff) | |
| parent | 0a9933ebf3704540a5f31225b26acb990e1de4bf (diff) | |
| download | cpython-97bd4b0cd9dec026bfaa66f492f1ea3c45abb1b1.zip cpython-97bd4b0cd9dec026bfaa66f492f1ea3c45abb1b1.tar.gz cpython-97bd4b0cd9dec026bfaa66f492f1ea3c45abb1b1.tar.bz2 | |
Asyncio issue 222 / PR 231 (Victor Stinner) -- fix @coroutine functions without __name__. (Merged from 3.4 branch.)
Diffstat (limited to 'Lib/asyncio/events.py')
| -rw-r--r-- | Lib/asyncio/events.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index 8a7bb81..3b907c6 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -54,15 +54,21 @@ def _format_callback(func, args, suffix=''): suffix = _format_args(args) + suffix return _format_callback(func.func, func.args, suffix) - func_repr = getattr(func, '__qualname__', None) - if not func_repr: + if hasattr(func, '__qualname__'): + func_repr = getattr(func, '__qualname__') + elif hasattr(func, '__name__'): + func_repr = getattr(func, '__name__') + else: func_repr = repr(func) if args is not None: func_repr += _format_args(args) if suffix: func_repr += suffix + return func_repr +def _format_callback_source(func, args): + func_repr = _format_callback(func, args) source = _get_function_source(func) if source: func_repr += ' at %s:%s' % source @@ -92,7 +98,7 @@ class Handle: if self._cancelled: info.append('cancelled') if self._callback is not None: - info.append(_format_callback(self._callback, self._args)) + info.append(_format_callback_source(self._callback, self._args)) if self._source_traceback: frame = self._source_traceback[-1] info.append('created at %s:%s' % (frame[0], frame[1])) @@ -119,7 +125,7 @@ class Handle: try: self._callback(*self._args) except Exception as exc: - cb = _format_callback(self._callback, self._args) + cb = _format_callback_source(self._callback, self._args) msg = 'Exception in callback {}'.format(cb) context = { 'message': msg, |
