-
-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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> (cherry picked from commit 42d873c) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
- Loading branch information
1 parent
2a86ade
commit 90115a2
Showing
3 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Library/2020-10-29-11-17-35.bpo-42183.50ZcIi.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Fix a stack overflow error for asyncio Task or Future repr(). | ||
|
||
The overflow occurs under some circumstances when a Task or Future | ||
recursively returns itself. |