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 @@ -735,7 +735,7 @@ def _done_callback(fut):
735
735
nonlocal nfinished
736
736
nfinished += 1
737
737
738
- if outer .done ():
738
+ if outer is None or outer .done ():
739
739
if not fut .cancelled ():
740
740
# Mark exception retrieved.
741
741
fut .exception ()
@@ -791,6 +791,7 @@ def _done_callback(fut):
791
791
nfuts = 0
792
792
nfinished = 0
793
793
loop = None
794
+ outer = None # bpo-46672
794
795
for arg in coros_or_futures :
795
796
if arg not in arg_to_fut :
796
797
fut = _ensure_future (arg , loop = loop )
Original file line number Diff line number Diff line change @@ -3235,6 +3235,20 @@ async def outer():
3235
3235
test_utils .run_briefly (self .one_loop )
3236
3236
self .assertIsInstance (f .exception (), RuntimeError )
3237
3237
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
+
3238
3252
3239
3253
class RunCoroutineThreadsafeTests (test_utils .TestCase ):
3240
3254
"""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