Skip to content

threading: fix ExceptHookArgs being a function instead of a type #4768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions stdlib/2and3/_dummy_threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,7 @@ class Event:
def wait(self, timeout: Optional[float] = ...) -> bool: ...

if sys.version_info >= (3, 8):
import _thread

# don't ask...
_ExceptHookArgs = _thread.ExceptHookArgs
ExceptHookArgs = _thread._ExceptHookArgs

excepthook: Callable[[_ExceptHookArgs], Any]
from _thread import _excepthook as excepthook, _ExceptHookArgs as ExceptHookArgs

class Timer(Thread):
if sys.version_info >= (3,):
Expand Down
8 changes: 1 addition & 7 deletions stdlib/2and3/threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,7 @@ class Event:
def wait(self, timeout: Optional[float] = ...) -> bool: ...

if sys.version_info >= (3, 8):
import _thread

# don't ask...
_ExceptHookArgs = _thread.ExceptHookArgs
ExceptHookArgs = _thread._ExceptHookArgs

excepthook: Callable[[_ExceptHookArgs], Any]
from _thread import _excepthook as excepthook, _ExceptHookArgs as ExceptHookArgs

class Timer(Thread):
if sys.version_info >= (3,):
Expand Down
19 changes: 11 additions & 8 deletions stdlib/3/_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from threading import Thread
from types import TracebackType
from typing import Any, Callable, Dict, NamedTuple, NoReturn, Optional, Tuple, Type
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type

error = RuntimeError

Expand Down Expand Up @@ -29,10 +29,13 @@ TIMEOUT_MAX: float

if sys.version_info >= (3, 8):
def get_native_id() -> int: ... # only available on some platforms
class ExceptHookArgs(NamedTuple):
exc_type: Type[BaseException]
exc_value: Optional[BaseException]
exc_traceback: Optional[TracebackType]
thread: Optional[Thread]
def _ExceptHookArgs(args: Any) -> ExceptHookArgs: ...
_excepthook: Callable[[ExceptHookArgs], Any]
class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]):
@property
def exc_type(self) -> Type[BaseException]: ...
@property
def exc_value(self) -> Optional[BaseException]: ...
@property
def exc_traceback(self) -> Optional[TracebackType]: ...
@property
def thread(self) -> Optional[Thread]: ...
_excepthook: Callable[[_ExceptHookArgs], Any]
2 changes: 0 additions & 2 deletions tests/stubtest_whitelists/py38.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
_thread.ExceptHookArgs
_thread._ExceptHookArgs
ast.Bytes.__new__
ast.Ellipsis.__new__
ast.NameConstant.__new__
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_whitelists/py39.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
_ast.ImportFrom.level
_dummy_thread
_thread.ExceptHookArgs
_thread._ExceptHookArgs
ast.Bytes.__new__
ast.Ellipsis.__new__
ast.ExtSlice.__new__
Expand Down