2 from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Tuple, Type, Union
3 from typing_extensions import final
8 bytes_types: Tuple[Type[Any], ...] # undocumented
10 class _ReadableFileobj(Protocol):
11 def read(self, __n: int) -> bytes: ...
12 def readline(self) -> bytes: ...
14 class _WritableFileobj(Protocol):
15 def write(self, __b: bytes) -> Any: ...
17 if sys.version_info >= (3, 8):
18 # TODO: holistic design for buffer interface (typing.Buffer?)
21 # buffer must be a buffer-providing object
22 def __init__(self, buffer: Any) -> None: ...
23 def raw(self) -> memoryview: ...
24 def release(self) -> None: ...
25 _BufferCallback = Optional[Callable[[PickleBuffer], Any]]
28 file: _WritableFileobj,
29 protocol: int | None = ...,
31 fix_imports: bool = ...,
32 buffer_callback: _BufferCallback = ...,
35 obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
38 file: _ReadableFileobj,
40 fix_imports: bool = ...,
43 buffers: Iterable[Any] | None = ...,
46 __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ...
50 def dump(obj: Any, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
51 def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ...
52 def load(file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
53 def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
55 class PickleError(Exception): ...
56 class PicklingError(PickleError): ...
57 class UnpicklingError(PickleError): ...
61 Tuple[Callable[..., Any], Tuple[Any, ...]],
62 Tuple[Callable[..., Any], Tuple[Any, ...], Any],
63 Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]],
64 Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]],
69 dispatch_table: Mapping[type, Callable[[Any], _reducedtype]]
70 bin: bool # undocumented
71 dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]] # undocumented, _Pickler only
73 if sys.version_info >= (3, 8):
76 file: _WritableFileobj,
77 protocol: int | None = ...,
79 fix_imports: bool = ...,
80 buffer_callback: _BufferCallback = ...,
82 def reducer_override(self, obj: Any) -> Any: ...
84 def __init__(self, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
85 def dump(self, __obj: Any) -> None: ...
86 def clear_memo(self) -> None: ...
87 def persistent_id(self, obj: Any) -> Any: ...
90 dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]] # undocumented, _Unpickler only
92 if sys.version_info >= (3, 8):
95 file: _ReadableFileobj,
97 fix_imports: bool = ...,
100 buffers: Iterable[Any] | None = ...,
104 self, file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...
106 def load(self) -> Any: ...
107 def find_class(self, __module_name: str, __global_name: str) -> Any: ...
108 def persistent_load(self, pid: Any) -> Any: ...
127 SHORT_BINSTRING: bytes
171 SHORT_BINBYTES: bytes
174 SHORT_BINUNICODE: bytes
185 if sys.version_info >= (3, 8):
189 READONLY_BUFFER: bytes
191 def encode_long(x: int) -> bytes: ... # undocumented
192 def decode_long(data: bytes) -> int: ... # undocumented
194 # pure-Python implementations
195 _Pickler = Pickler # undocumented
196 _Unpickler = Unpickler # undocumented