From 70e9748f18f48cef95c23d433f39c01358ac8ce3 Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Thu, 29 Aug 2024 10:10:17 -0500 Subject: [PATCH] Fix `_thread.interrupt_main` for 3.10+ (#12586) --- stdlib/@tests/stubtest_allowlists/py313.txt | 1 - stdlib/_thread.pyi | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 5b0741b40..37fe35f77 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -3,7 +3,6 @@ # ========================= # TODO: triage these new errors -_thread.interrupt_main _thread.lock _thread.start_joinable_thread _tkinter.create diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 304cb79ec..97f8d37cb 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,3 +1,4 @@ +import signal import sys from _typeshed import structseq from collections.abc import Callable @@ -25,7 +26,13 @@ class LockType: def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... @overload def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... -def interrupt_main() -> None: ... + +if sys.version_info >= (3, 10): + def interrupt_main(signum: signal.Signals = ..., /) -> None: ... + +else: + def interrupt_main() -> None: ... + def exit() -> NoReturn: ... def allocate_lock() -> LockType: ... def get_ident() -> int: ...