New submission from arl <genericusername...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue46672> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com