From a30db1cb6e5815e24ea13083d68ada192287a65d Mon Sep 17 00:00:00 2001 From: Emmanuel Ferdman Date: Sat, 14 Feb 2026 02:26:25 +0200 Subject: [PATCH 1/2] [stdlib] Add missing pickle methods in multiprocessing.queues Signed-off-by: Emmanuel Ferdman --- stdlib/multiprocessing/queues.pyi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index a6b00d744c42..04d0b8200998 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -10,6 +10,8 @@ class Queue(Generic[_T]): # FIXME: `ctx` is a circular dependency and it's not actually optional. # It's marked as such to be able to use the generic Queue in __init__.pyi. def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ... + def __getstate__(self) -> object: ... + def __setstate__(self, state: object) -> None: ... def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ... def get(self, block: bool = True, timeout: float | None = None) -> _T: ... def qsize(self) -> int: ... @@ -31,6 +33,8 @@ class SimpleQueue(Generic[_T]): def __init__(self, *, ctx: Any = ...) -> None: ... def close(self) -> None: ... def empty(self) -> bool: ... + def __getstate__(self) -> object: ... + def __setstate__(self, state: object) -> None: ... def get(self) -> _T: ... def put(self, obj: _T) -> None: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... From de285f36561ad3ba2a22a5dcf2162a88f70362be Mon Sep 17 00:00:00 2001 From: Emmanuel Ferdman Date: Fri, 20 Feb 2026 20:42:35 +0200 Subject: [PATCH 2/2] [stdlib] Add missing pickle methods in multiprocessing.queues Signed-off-by: Emmanuel Ferdman --- stdlib/multiprocessing/queues.pyi | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index 04d0b8200998..8f0feb834619 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -1,17 +1,21 @@ import sys from types import GenericAlias -from typing import Any, Generic, TypeVar +from typing import Any, Generic, NewType, TypeVar __all__ = ["Queue", "SimpleQueue", "JoinableQueue"] _T = TypeVar("_T") +_QueueState = NewType("_QueueState", object) +_JoinableQueueState = NewType("_JoinableQueueState", object) +_SimpleQueueState = NewType("_SimpleQueueState", object) + class Queue(Generic[_T]): # FIXME: `ctx` is a circular dependency and it's not actually optional. # It's marked as such to be able to use the generic Queue in __init__.pyi. def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ... - def __getstate__(self) -> object: ... - def __setstate__(self, state: object) -> None: ... + def __getstate__(self) -> _QueueState: ... + def __setstate__(self, state: _QueueState) -> None: ... def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ... def get(self, block: bool = True, timeout: float | None = None) -> _T: ... def qsize(self) -> int: ... @@ -26,6 +30,8 @@ class Queue(Generic[_T]): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... class JoinableQueue(Queue[_T]): + def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override] + def __setstate__(self, state: _JoinableQueueState) -> None: ... # type: ignore[override] def task_done(self) -> None: ... def join(self) -> None: ... @@ -33,8 +39,8 @@ class SimpleQueue(Generic[_T]): def __init__(self, *, ctx: Any = ...) -> None: ... def close(self) -> None: ... def empty(self) -> bool: ... - def __getstate__(self) -> object: ... - def __setstate__(self, state: object) -> None: ... + def __getstate__(self) -> _SimpleQueueState: ... + def __setstate__(self, state: _SimpleQueueState) -> None: ... def get(self) -> _T: ... def put(self, obj: _T) -> None: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...