bpo-38785: Prevent asyncio from crashing (GH-17144)

if parent `__init__` is not called from a constructor of object derived from `asyncio.Future`



https://bugs.python.org/issue38785
This commit is contained in:
Andrew Svetlov 2019-11-13 23:36:46 +02:00 committed by Miss Islington (bot)
parent 61289d4366
commit dad6be5ffe
4 changed files with 46 additions and 1 deletions

View file

@ -115,7 +115,10 @@ class Future:
def get_loop(self):
"""Return the event loop the Future is bound to."""
return self._loop
loop = self._loop
if loop is None:
raise RuntimeError("Future object is not initialized.")
return loop
def cancel(self):
"""Cancel the future and schedule callbacks.