Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,32 @@ class Future(futures._PyFuture):
pass


@unittest.skipUnless(hasattr(tasks, '_CTask'),
'requires the C _asyncio module')
class CTask_Future_Tests(test_utils.TestCase):

def test_foobar(self):
class Fut(asyncio.Future):
@property
def get_loop(self):
raise AttributeError

async def coro():
await fut
return 'spam'

self.loop = asyncio.new_event_loop()
try:
fut = Fut(loop=self.loop)
self.loop.call_later(0.1, fut.set_result(1))
task = asyncio.Task(coro(), loop=self.loop)
res = self.loop.run_until_complete(task)
finally:
self.loop.close()

self.assertEqual(res, 'spam')


class BaseTaskIntrospectionTests:
_register_task = None
_unregister_task = None
Expand Down
1 change: 1 addition & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ get_future_loop(PyObject *fut)
return res;
}

PyErr_Clear();
return _PyObject_GetAttrId(fut, &PyId__loop);
}

Expand Down