mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
asyncio: Future.set_exception(exc) should instantiate exc if it is a class.
This commit is contained in:
parent
91445fbeb0
commit
9572898282
2 changed files with 7 additions and 0 deletions
|
@ -301,6 +301,8 @@ class Future:
|
|||
"""
|
||||
if self._state != _PENDING:
|
||||
raise InvalidStateError('{}: {!r}'.format(self._state, self))
|
||||
if isinstance(exception, type):
|
||||
exception = exception()
|
||||
self._exception = exception
|
||||
self._state = _FINISHED
|
||||
self._schedule_callbacks()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue