Commit 719ccbca authored by Yury Selivanov's avatar Yury Selivanov Committed by GitHub

bpo-32415: Fix "error is already set" (#4999)

parent a330f483
......@@ -2302,6 +2302,32 @@ class PyTask_PyFuture_SubclassTests(BaseTaskTests, test_utils.TestCase):
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
......
......@@ -203,6 +203,7 @@ get_future_loop(PyObject *fut)
return res;
}
PyErr_Clear();
return _PyObject_GetAttrId(fut, &PyId__loop);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment