nonlocal nfinished
nfinished += 1
- if outer.done():
+ if outer is None or outer.done():
if not fut.cancelled():
# Mark exception retrieved.
fut.exception()
children = []
nfuts = 0
nfinished = 0
+ outer = None # bpo-46672
for arg in coros_or_futures:
if arg not in arg_to_fut:
fut = ensure_future(arg, loop=loop)
coros.append(coro())
return coros
+ def _gather(self, *args, **kwargs):
+ async def coro():
+ return asyncio.gather(*args, **kwargs)
+ return self.one_loop.run_until_complete(coro())
+
def test_constructor_loop_selection(self):
async def coro():
return 'abc'
test_utils.run_briefly(self.one_loop)
self.assertIsInstance(f.exception(), RuntimeError)
+ def test_issue46672(self):
+ with mock.patch(
+ 'asyncio.base_events.BaseEventLoop.call_exception_handler',
+ ):
+ async def coro(s):
+ return s
+ c = coro('abc')
+
+ with self.assertRaises(TypeError):
+ self._gather(c, {})
+ self._run_loop(self.one_loop)
+ # NameError should not happen:
+ self.one_loop.call_exception_handler.assert_not_called()
+
class RunCoroutineThreadsafeTests(test_utils.TestCase):
"""Test case for asyncio.run_coroutine_threadsafe."""