From 4ab8167b9c60d1a04b2e3116d0c52db254b68cda Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 20 Feb 2022 13:24:00 +0300 Subject: bpo-46672: fix `NameError` in `asyncio.gather` if type check fails (GH-31187) Co-authored-by: Alex Waygood --- Lib/asyncio/tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/asyncio') diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index c11d0daaefe..25a650ffbb7 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -735,7 +735,7 @@ def gather(*coros_or_futures, return_exceptions=False): nonlocal nfinished nfinished += 1 - if outer.done(): + if outer is None or outer.done(): if not fut.cancelled(): # Mark exception retrieved. fut.exception() @@ -791,6 +791,7 @@ def gather(*coros_or_futures, return_exceptions=False): nfuts = 0 nfinished = 0 loop = None + outer = None # bpo-46672 for arg in coros_or_futures: if arg not in arg_to_fut: fut = _ensure_future(arg, loop=loop) -- cgit v1.2.3