bpo-24638: Improve the error message in asyncio.ensure_future() (#12848)
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 007a459..b007b74 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -628,7 +628,8 @@
return task
elif futures.isfuture(coro_or_future):
if loop is not None and loop is not futures._get_loop(coro_or_future):
- raise ValueError('loop argument must agree with Future')
+ raise ValueError('The future belongs to a different loop than '
+ 'the one specified as the loop argument')
return coro_or_future
elif inspect.isawaitable(coro_or_future):
return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)