Skip to content

Pickle 5 #3636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions stdlib/2and3/pickle.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
import sys
from typing import Any, IO, Mapping, Union, Tuple, Callable, Optional, Iterator
from typing import Any, IO, Mapping, Union, Tuple, Callable, Optional, Iterable, Iterator

HIGHEST_PROTOCOL: int
if sys.version_info >= (3, 0):
DEFAULT_PROTOCOL: int


if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
# TODO: holistic design for buffer interface (typing.Buffer?)

class PickleBuffer:
# buffer must be a buffer-providing object
def __init__(self, buffer: Any) -> None: ...
def raw(self) -> memoryview: ...
def release(self) -> None: ...

_BufferCallback = Optional[Callable[[PickleBuffer], Any]]

def dump(
obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...
) -> None: ...
def dumps(
obj: Any, protocol: Optional[int] = ..., *,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...
) -> bytes: ...
def load(
file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ..., buffers: Optional[Iterable[Any]] = ...
) -> Any: ...
def loads(
data: bytes, *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ..., buffers: Optional[Iterable[Any]] = ...
) -> Any: ...
elif sys.version_info >= (3, 0):
def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> None: ...
def dumps(obj: Any, protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> bytes: ...
def loads(bytes_object: bytes, *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> Any: ...
def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ...) -> Any: ...
def loads(data: bytes, *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> Any: ...
else:
def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ...
def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ...
Expand All @@ -39,7 +68,12 @@ class Pickler:
if sys.version_info >= (3, 3):
dispatch_table: Mapping[type, Callable[[Any], _reducedtype]]

if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> None: ...
def reducer_override(self, obj: Any) -> Any: ...
elif sys.version_info >= (3, 0):
def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> None: ...
else:
Expand All @@ -52,7 +86,11 @@ class Pickler:
def reducer_override(self, obj: Any) -> Any: ...

class Unpickler:
if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
def __init__(self, file: IO[bytes], *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...,
buffers: Optional[Iterable[Any]] = ...) -> None: ...
elif sys.version_info >= (3, 0):
def __init__(self, file: IO[bytes], *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> None: ...
else:
Expand Down