summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2023-06-26 08:51:28 (GMT)
committerGitHub <noreply@github.com>2023-06-26 08:51:28 (GMT)
commit9e6f8d46150c1a0af09d68ce63c603cf321994aa (patch)
tree4aa21a36c84f039425ae9e9583181385b0bbf616 /Lib/test
parent84189640b72cb64d8be297ac1574351f7a611d2a (diff)
downloadcpython-9e6f8d46150c1a0af09d68ce63c603cf321994aa.zip
cpython-9e6f8d46150c1a0af09d68ce63c603cf321994aa.tar.gz
cpython-9e6f8d46150c1a0af09d68ce63c603cf321994aa.tar.bz2
[3.12] gh-105987: Fix reference counting issue in `_asyncio._swap_cur… (#106099)
[3.12] gh-105987: Fix reference counting issue in `_asyncio._swap_current_task` (GH-105989). (cherry picked from commit d2cbb6e918d9ea39f0dd44acb53270f2dac07454) Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_eager_task_factory.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_eager_task_factory.py b/Lib/test/test_asyncio/test_eager_task_factory.py
index fe69093..3468887 100644
--- a/Lib/test/test_asyncio/test_eager_task_factory.py
+++ b/Lib/test/test_asyncio/test_eager_task_factory.py
@@ -12,7 +12,7 @@ from asyncio import base_events
from asyncio import tasks
from test.test_asyncio import utils as test_utils
from test.test_asyncio.test_tasks import get_innermost_context
-from test import support
+from test.support.script_helper import assert_python_ok
MOCK_ANY = mock.ANY
@@ -228,6 +228,23 @@ class PyEagerTaskFactoryLoopTests(EagerTaskFactoryLoopTests, test_utils.TestCase
class CEagerTaskFactoryLoopTests(EagerTaskFactoryLoopTests, test_utils.TestCase):
Task = getattr(tasks, '_CTask', None)
+ def test_issue105987(self):
+ code = """if 1:
+ from _asyncio import _swap_current_task
+
+ class DummyTask:
+ pass
+
+ class DummyLoop:
+ pass
+
+ l = DummyLoop()
+ _swap_current_task(l, DummyTask())
+ t = _swap_current_task(l, None)
+ """
+
+ _, out, err = assert_python_ok("-c", code)
+ self.assertFalse(err)
class AsyncTaskCounter:
def __init__(self, loop, *, task_class, eager):