Fix CPython issue #25966: must check for None result from _get_functi… · python/asyncio@0c3e6ec (original) (raw)
`@@ -27,8 +27,8 @@
`
27
27
`# before you define your coroutines. A downside of using this feature
`
28
28
`# is that tracebacks show entries for the CoroWrapper.next method
`
29
29
`# when _DEBUG is true.
`
30
``
`-
_DEBUG = (not sys.flags.ignore_environment
`
31
``
`-
and bool(os.environ.get('PYTHONASYNCIODEBUG')))
`
``
30
`+
_DEBUG = (not sys.flags.ignore_environment and
`
``
31
`+
bool(os.environ.get('PYTHONASYNCIODEBUG')))
`
32
32
``
33
33
``
34
34
`try:
`
`@@ -86,7 +86,7 @@ class CoroWrapper:
`
86
86
`def init(self, gen, func=None):
`
87
87
`assert inspect.isgenerator(gen) or inspect.iscoroutine(gen), gen
`
88
88
`self.gen = gen
`
89
``
`-
self.func = func # Used to unwrap @coroutine decorator
`
``
89
`+
self.func = func # Used to unwrap @coroutine decorator
`
90
90
`self._source_traceback = traceback.extract_stack(sys._getframe(1))
`
91
91
`self.name = getattr(gen, 'name', None)
`
92
92
`self.qualname = getattr(gen, 'qualname', None)
`
`@@ -283,10 +283,13 @@ def _format_coroutine(coro):
`
283
283
`coro_frame = coro.cr_frame
`
284
284
``
285
285
`filename = coro_code.co_filename
`
286
``
`-
if (isinstance(coro, CoroWrapper)
`
287
``
`-
and not inspect.isgeneratorfunction(coro.func)
`
288
``
`-
and coro.func is not None):
`
289
``
`-
filename, lineno = events._get_function_source(coro.func)
`
``
286
`+
lineno = 0
`
``
287
`+
if (isinstance(coro, CoroWrapper) and
`
``
288
`+
not inspect.isgeneratorfunction(coro.func) and
`
``
289
`+
coro.func is not None):
`
``
290
`+
source = events._get_function_source(coro.func)
`
``
291
`+
if source is not None:
`
``
292
`+
filename, lineno = source
`
290
293
`if coro_frame is None:
`
291
294
`coro_repr = ('%s done, defined at %s:%s'
`
292
295
`% (coro_name, filename, lineno))
`