[New-bugs-announce] [issue46672] NameError in asyncio.gather when passing a invalid type as an arg with multiple awaitables
arl
report at bugs.python.org
Mon Feb 7 00:24:45 EST 2022
New submission from arl <genericusername414 at gmail.com>:
It is possible to cause a NameError in asyncio.gather if the second presumed coroutine fails the internal type check.
Sample code:
import asyncio
async def main():
coros = (asyncio.sleep(1), {1: 1})
await asyncio.gather(*coros)
asyncio.run(main())
Exception in callback gather.<locals>._done_callback(<Task cancell...tasks.py:593>>) at /usr/local/lib/python3.10/asyncio/tasks.py:714
handle: <Handle gather.<locals>._done_callback(<Task cancell...tasks.py:593>>) at /usr/local/lib/python3.10/asyncio/tasks.py:714>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "<string>", line 4, in main
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 775, in gather
if arg not in arg_to_fut:
TypeError: unhashable type: 'dict'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 718, in _done_callback
if outer.done():
NameError: free variable 'outer' referenced before assignment in enclosing scope
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "<string>", line 4, in main
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 775, in gather
if arg not in arg_to_fut:
TypeError: unhashable type: 'dict'
----------
components: asyncio
messages: 412709
nosy: asvetlov, onerandomusername, yselivanov
priority: normal
severity: normal
status: open
title: NameError in asyncio.gather when passing a invalid type as an arg with multiple awaitables
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46672>
_______________________________________
More information about the New-bugs-announce
mailing list