Use BaseException for Future.exception() and .set_exception(). (#935)

The concurrent.futures.Future class's set_exception() method might be
called with a BaseException that is not an Exception, so change
set_exception()'s parameter type from Exception to BaseException.  The
exception set via set_exception() is returned by exception(), so
change exception()'s return type from Exception to BaseException.
This commit is contained in:
Richard Hansen
2017-02-15 11:19:49 -05:00
committed by Guido van Rossum
parent 43d7747f59
commit 55d4c08a8e
2 changed files with 4 additions and 4 deletions

View File

@@ -27,10 +27,10 @@ class Future(Generic[_T]):
def done(self) -> bool: ...
def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ...
def result(self, timeout: Optional[float] = ...) -> _T: ...
def exception(self, timeout: Optional[float] = ...) -> Exception: ...
def exception(self, timeout: Optional[float] = ...) -> BaseException: ...
def set_running_or_notify_cancel(self) -> None: ...
def set_result(self, result: _T) -> None: ...
def set_exception(self, exception: Exception) -> None: ...
def set_exception(self, exception: BaseException) -> None: ...
class Executor:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...