summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-02-20 07:28:42 -0800
committerGitHub <noreply@github.com>2022-02-20 17:28:42 +0200
commitf1916cde24053f4c8b6799730666d19474f8dd09 (patch)
treead1ddb5fe008f435f2f7fdd3153c3e8a9eb5075b /Lib/test/test_asyncio/test_tasks.py
parentfa621a738875dc8a644a6149e7ffd4be0a40f1d9 (diff)
downloadcpython-git-f1916cde24053f4c8b6799730666d19474f8dd09.tar.gz
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 4ab8167b9c60d1a04b2e3116d0c52db254b68cda) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 4782c92a7c..398b143d2d 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -3593,6 +3593,20 @@ class CoroutineGatherTests(GatherTestsBase, test_utils.TestCase):
test_utils.run_briefly(self.one_loop)
self.assertIsInstance(f.exception(), RuntimeError)
+ def test_issue46672(self):
+ with mock.patch(
+ 'asyncio.base_events.BaseEventLoop.call_exception_handler',
+ ):
+ async def coro(s):
+ return s
+ c = coro('abc')
+
+ with self.assertRaises(TypeError):
+ self._gather(c, {})
+ self._run_loop(self.one_loop)
+ # NameError should not happen:
+ self.one_loop.call_exception_handler.assert_not_called()
+
class RunCoroutineThreadsafeTests(test_utils.TestCase):
"""Test case for asyncio.run_coroutine_threadsafe."""