Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc086962

Browse files
gh-122332: Fix missingNULL check inasyncio.Task.get_coro (#122338)
1 parent863a92f commitc086962

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

‎Lib/test/test_asyncio/test_eager_task_factory.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ class DummyLoop:
241241
_,out,err=assert_python_ok("-c",code)
242242
self.assertFalse(err)
243243

244+
deftest_issue122332(self):
245+
asyncdefcoro():
246+
pass
247+
248+
asyncdefrun():
249+
task=self.loop.create_task(coro())
250+
awaittask
251+
self.assertIsNone(task.get_coro())
252+
253+
self.run_coro(run())
254+
255+
244256
classAsyncTaskCounter:
245257
def__init__(self,loop,*,task_class,eager):
246258
self.suspense_count=0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed segfault with:meth:`asyncio.Task.get_coro` when using an eager task
2+
factory.

‎Modules/_asynciomodule.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,11 @@ static PyObject *
25002500
_asyncio_Task_get_coro_impl(TaskObj*self)
25012501
/*[clinic end generated code: output=bcac27c8cc6c8073 input=d2e8606c42a7b403]*/
25022502
{
2503-
returnPy_NewRef(self->task_coro);
2503+
if (self->task_coro) {
2504+
returnPy_NewRef(self->task_coro);
2505+
}
2506+
2507+
Py_RETURN_NONE;
25042508
}
25052509

25062510
/*[clinic input]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp