From 2aaa83d8ab6adb1258e8160554aa01470d181fe2 Mon Sep 17 00:00:00 2001 From: ANSHUL SINGH <72524975+ekanshul@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:19:22 +0530 Subject: [PATCH] multiprocessing.connection: allow bytes addresses Co-Authored-By: Claude Fable 5 --- stdlib/multiprocessing/connection.pyi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index e8366e9a8ba5..c63e6920fc46 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -9,7 +9,8 @@ from typing_extensions import Self __all__ = ["Client", "Listener", "Pipe", "wait"] # https://docs.python.org/3/library/multiprocessing.html#address-formats -_Address: TypeAlias = str | tuple[str, int] +# bytes: Linux abstract AF_UNIX socket name (starts with a null byte) +_Address: TypeAlias = str | bytes | tuple[str, int] # Defaulting to Any to avoid forcing generics on a lot of pre-existing code _SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=Any) @@ -52,10 +53,12 @@ class Listener: def accept(self) -> Connection[Incomplete, Incomplete] | PipeConnection[Incomplete, Incomplete]: ... def close(self) -> None: ... + # Any: the concrete type depends on the address family and platform + # (e.g. str or bytes for AF_UNIX), cf. _socket._RetAddress @property - def address(self) -> _Address: ... + def address(self) -> Any: ... @property - def last_accepted(self) -> _Address | None: ... + def last_accepted(self) -> Any | None: ... def __enter__(self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: TracebackType | None