File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -768,7 +768,7 @@ def _done_callback(fut):
768
768
nonlocal nfinished
769
769
nfinished += 1
770
770
771
- if outer .done ():
771
+ if outer is None or outer .done ():
772
772
if not fut .cancelled ():
773
773
# Mark exception retrieved.
774
774
fut .exception ()
@@ -823,6 +823,8 @@ def _done_callback(fut):
823
823
children = []
824
824
nfuts = 0
825
825
nfinished = 0
826
+ loop = None
827
+ outer = None # bpo-46672
826
828
for arg in coros_or_futures :
827
829
if arg not in arg_to_fut :
828
830
fut = ensure_future (arg , loop = loop )
Original file line number Diff line number Diff line change @@ -3488,6 +3488,20 @@ async def outer():
3488
3488
test_utils .run_briefly (self .one_loop )
3489
3489
self .assertIsInstance (f .exception (), RuntimeError )
3490
3490
3491
+ def test_issue46672 (self ):
3492
+ with mock .patch (
3493
+ 'asyncio.base_events.BaseEventLoop.call_exception_handler' ,
3494
+ ):
3495
+ async def coro (s ):
3496
+ return s
3497
+ c = coro ('abc' )
3498
+
3499
+ with self .assertRaises (TypeError ):
3500
+ self ._gather (c , {})
3501
+ self ._run_loop (self .one_loop )
3502
+ # NameError should not happen:
3503
+ self .one_loop .call_exception_handler .assert_not_called ()
3504
+
3491
3505
3492
3506
class RunCoroutineThreadsafeTests (test_utils .TestCase ):
3493
3507
"""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