Bug report
Bug description:
asyncio.Task(coro, eager_start=True) raises AttributeError when the loop is not passed
Reproducer:
import asyncio
async def coro():
return 42
async def main():
t = asyncio.Task(coro(), eager_start=True)
print(t.done(), await t)
asyncio.run(main())
Expected:
But actually:
AttributeError: 'NoneType' object has no attribute 'is_running'
For example python implementation of the Task works correctly:
import asyncio
import asyncio.tasks
async def coro():
return 42
async def main():
task = asyncio.tasks._PyTask(coro(), eager_start=True)
print(task.done(), await task)
asyncio.run(main())
Output:
Proposed fix:
From:
PyObject *res = PyObject_CallMethodNoArgs(loop, &_Py_ID(is_running));
To:
PyObject *res = PyObject_CallMethodNoArgs(self->task_loop,
&_Py_ID(is_running));
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
asyncio.Task(coro, eager_start=True)raisesAttributeErrorwhen theloopis not passedReproducer:
Expected:
But actually:
For example python implementation of the Task works correctly:
Output:
Proposed fix:
From:
To:
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs