File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ def _done_callback(fut):
735735 nonlocal nfinished
736736 nfinished += 1
737737
738- if outer .done ():
738+ if outer is None or outer .done ():
739739 if not fut .cancelled ():
740740 # Mark exception retrieved.
741741 fut .exception ()
@@ -791,6 +791,7 @@ def _done_callback(fut):
791791 nfuts = 0
792792 nfinished = 0
793793 loop = None
794+ outer = None # bpo-46672
794795 for arg in coros_or_futures :
795796 if arg not in arg_to_fut :
796797 fut = _ensure_future (arg , loop = loop )
Original file line number Diff line number Diff line change @@ -3235,6 +3235,20 @@ async def outer():
32353235 test_utils .run_briefly (self .one_loop )
32363236 self .assertIsInstance (f .exception (), RuntimeError )
32373237
3238+ def test_issue46672 (self ):
3239+ with mock .patch (
3240+ 'asyncio.base_events.BaseEventLoop.call_exception_handler' ,
3241+ ):
3242+ async def coro (s ):
3243+ return s
3244+ c = coro ('abc' )
3245+
3246+ with self .assertRaises (TypeError ):
3247+ self ._gather (c , {})
3248+ self ._run_loop (self .one_loop )
3249+ # NameError should not happen:
3250+ self .one_loop .call_exception_handler .assert_not_called ()
3251+
32383252
32393253class RunCoroutineThreadsafeTests (test_utils .TestCase ):
32403254 """Test case for asyncio.run_coroutine_threadsafe."""
Original file line number Diff line number Diff line change 1+ Fix ``NameError `` in :func: `asyncio.gather ` when initial type check fails.
You can’t perform that action at this time.
0 commit comments