From de2a42713ab510a69f71fafb7ae222b690459bf0 Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Wed, 29 Oct 2025 10:38:22 -0400 Subject: [PATCH] Add type stub for `sys._current_exceptions` (#14937) Co-authored-by: Alex Waygood --- stdlib/sys/__init__.pyi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/sys/__init__.pyi b/stdlib/sys/__init__.pyi index 0f6f2587a..c58ab9e2a 100644 --- a/stdlib/sys/__init__.pyi +++ b/stdlib/sys/__init__.pyi @@ -354,6 +354,13 @@ else: def _current_frames() -> dict[int, FrameType]: ... def _getframe(depth: int = 0, /) -> FrameType: ... +# documented -- see https://docs.python.org/3/library/sys.html#sys._current_exceptions +if sys.version_info >= (3, 12): + def _current_exceptions() -> dict[int, BaseException | None]: ... + +else: + def _current_exceptions() -> dict[int, OptExcInfo]: ... + if sys.version_info >= (3, 12): def _getframemodulename(depth: int = 0) -> str | None: ...