diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2020-11-10 13:58:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 13:58:31 (GMT) |
commit | 42d873c63aa9d160c132be4a34599531574db12c (patch) | |
tree | 52d68f9f283cfe6c7b91239f7bce075ed1e1f418 /Lib/test/test_asyncio/test_futures2.py | |
parent | 0b9c4c6fcf2b0673fa45ddfa092934a9d5479b8c (diff) | |
download | cpython-42d873c63aa9d160c132be4a34599531574db12c.zip cpython-42d873c63aa9d160c132be4a34599531574db12c.tar.gz cpython-42d873c63aa9d160c132be4a34599531574db12c.tar.bz2 |
bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020)
The overflow occurs under some circumstances when a task or future
recursively returns itself.
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
Diffstat (limited to 'Lib/test/test_asyncio/test_futures2.py')
-rw-r--r-- | Lib/test/test_asyncio/test_futures2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_futures2.py b/Lib/test/test_asyncio/test_futures2.py new file mode 100644 index 0000000..13dbc70 --- /dev/null +++ b/Lib/test/test_asyncio/test_futures2.py @@ -0,0 +1,18 @@ +# IsolatedAsyncioTestCase based tests +import asyncio +import unittest + + +class FutureTests(unittest.IsolatedAsyncioTestCase): + async def test_recursive_repr_for_pending_tasks(self): + # The call crashes if the guard for recursive call + # in base_futures:_future_repr_info is absent + # See Also: https://bugs.python.org/issue42183 + + async def func(): + return asyncio.all_tasks() + + # The repr() call should not raise RecursiveError at first. + # The check for returned string is not very reliable but + # exact comparison for the whole string is even weaker. + self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10))) |