File tree 3 files changed +17
-1
lines changed
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):
721
721
nonlocal nfinished
722
722
nfinished += 1
723
723
724
- if outer .done ():
724
+ if outer is None or outer .done ():
725
725
if not fut .cancelled ():
726
726
# Mark exception retrieved.
727
727
fut .exception ()
@@ -777,6 +777,7 @@ def _done_callback(fut):
777
777
nfuts = 0
778
778
nfinished = 0
779
779
loop = None
780
+ outer = None # bpo-46672
780
781
for arg in coros_or_futures :
781
782
if arg not in arg_to_fut :
782
783
fut = _ensure_future (arg , loop = loop )
Original file line number Diff line number Diff line change @@ -3593,6 +3593,20 @@ async def outer():
3593
3593
test_utils .run_briefly (self .one_loop )
3594
3594
self .assertIsInstance (f .exception (), RuntimeError )
3595
3595
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
+
3596
3610
3597
3611
class RunCoroutineThreadsafeTests (test_utils .TestCase ):
3598
3612
"""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