From 190483248c3a66023ed43e6f623a6614938599c7 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Thu, 6 Aug 2026 09:56:51 +0200 Subject: [PATCH 1/2] Add mailbox.Mailbox enter/exit for Python 3.15 --- stdlib/@tests/stubtest_allowlists/py315.txt | 2 -- stdlib/mailbox.pyi | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py315.txt b/stdlib/@tests/stubtest_allowlists/py315.txt index 7354dac4dc90..38ae4bfef87e 100644 --- a/stdlib/@tests/stubtest_allowlists/py315.txt +++ b/stdlib/@tests/stubtest_allowlists/py315.txt @@ -28,8 +28,6 @@ importlib.abc.InspectLoader.source_to_code importlib.abc.MetaPathFinder.discover importlib.abc.PathEntryFinder.discover importlib.resources._common.package_to_anchor -mailbox.Mailbox.__enter__ -mailbox.Mailbox.__exit__ mailbox._ProxyFile.__class_getitem__ multiprocessing.process.BaseProcess.__init__ threading.Condition.locked diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 961c0f5e81f7..6a7226c9e144 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -129,6 +129,11 @@ class Mailbox(Generic[_MessageT_co]): def unlock(self) -> None: ... @abstractmethod def close(self) -> None: ... + if sys.version_info >= (3, 15): + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... # Undocumented, called by subclasses to parse added messages. def _dump_message(self, message: _MessageData, target: SupportsWrite[bytes], mangle_from_: bool = False) -> None: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... From 5bde6608f94145d657694b52e3175a7588d1db01 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Thu, 6 Aug 2026 22:18:02 +0200 Subject: [PATCH 2/2] Update stdlib/mailbox.pyi Co-authored-by: Sebastian Rittau --- stdlib/mailbox.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 6a7226c9e144..4215120a5753 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -132,7 +132,7 @@ class Mailbox(Generic[_MessageT_co]): if sys.version_info >= (3, 15): def __enter__(self) -> Self: ... def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... # Undocumented, called by subclasses to parse added messages. def _dump_message(self, message: _MessageData, target: SupportsWrite[bytes], mangle_from_: bool = False) -> None: ...