[3.9] bpo-46672: fix NameError in asyncio.gather if type check fails (GH-31187) (GH-31441)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Andrew Svetlov 2022-02-20 14:39:21 +02:00 committed by GitHub
parent cf1993210f
commit a6116a980c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -768,7 +768,7 @@ def _done_callback(fut):
nonlocal nfinished
nfinished += 1
if outer.done():
if outer is None or outer.done():
if not fut.cancelled():
# Mark exception retrieved.
fut.exception()
@ -823,6 +823,7 @@ def _done_callback(fut):
children = []
nfuts = 0
nfinished = 0
outer = None # bpo-46672
for arg in coros_or_futures:
if arg not in arg_to_fut:
fut = ensure_future(arg, loop=loop)