mirror of https://github.com/python/cpython
[3.13] gh-122332: Fix missing `NULL` check in `asyncio.Task.get_coro` (GH-122338) (#122344)
gh-122332: Fix missing `NULL` check in `asyncio.Task.get_coro` (GH-122338)
(cherry picked from commit c08696286f
)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
7b35c50cd8
commit
6b9a5af72f
|
@ -241,6 +241,18 @@ class CEagerTaskFactoryLoopTests(EagerTaskFactoryLoopTests, test_utils.TestCase)
|
|||
_, out, err = assert_python_ok("-c", code)
|
||||
self.assertFalse(err)
|
||||
|
||||
def test_issue122332(self):
|
||||
async def coro():
|
||||
pass
|
||||
|
||||
async def run():
|
||||
task = self.loop.create_task(coro())
|
||||
await task
|
||||
self.assertIsNone(task.get_coro())
|
||||
|
||||
self.run_coro(run())
|
||||
|
||||
|
||||
class AsyncTaskCounter:
|
||||
def __init__(self, loop, *, task_class, eager):
|
||||
self.suspense_count = 0
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fixed segfault with :meth:`asyncio.Task.get_coro` when using an eager task
|
||||
factory.
|
|
@ -2450,7 +2450,11 @@ static PyObject *
|
|||
_asyncio_Task_get_coro_impl(TaskObj *self)
|
||||
/*[clinic end generated code: output=bcac27c8cc6c8073 input=d2e8606c42a7b403]*/
|
||||
{
|
||||
return Py_NewRef(self->task_coro);
|
||||
if (self->task_coro) {
|
||||
return Py_NewRef(self->task_coro);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
|
Loading…
Reference in New Issue