bpo-46672: fix NameError in asyncio.gather if type check fails (GH-31187) (GH-31440)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 4ab8167b9c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2022-02-20 07:28:42 -08:00 committed by GitHub
parent fa621a7388
commit f1916cde24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -721,7 +721,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()
@ -777,6 +777,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)