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 @@ -721,7 +721,7 @@ def _done_callback(fut):
721721 nonlocal nfinished
722722 nfinished += 1
723723
724- if outer .done ():
724+ if outer is None or outer .done ():
725725 if not fut .cancelled ():
726726 # Mark exception retrieved.
727727 fut .exception ()
@@ -777,6 +777,7 @@ def _done_callback(fut):
777777 nfuts = 0
778778 nfinished = 0
779779 loop = None
780+ outer = None # bpo-46672
780781 for arg in coros_or_futures :
781782 if arg not in arg_to_fut :
782783 fut = _ensure_future (arg , loop = loop )
Original file line number Diff line number Diff line change @@ -3593,6 +3593,20 @@ async def outer():
35933593 test_utils .run_briefly (self .one_loop )
35943594 self .assertIsInstance (f .exception (), RuntimeError )
35953595
3596+ def test_issue46672 (self ):
3597+ with mock .patch (
3598+ 'asyncio.base_events.BaseEventLoop.call_exception_handler' ,
3599+ ):
3600+ async def coro (s ):
3601+ return s
3602+ c = coro ('abc' )
3603+
3604+ with self .assertRaises (TypeError ):
3605+ self ._gather (c , {})
3606+ self ._run_loop (self .one_loop )
3607+ # NameError should not happen:
3608+ self .one_loop .call_exception_handler .assert_not_called ()
3609+
35963610
35973611class RunCoroutineThreadsafeTests (test_utils .TestCase ):
35983612 """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