From 6fec910c6666f59bcf45c7a72484db25f5351c99 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Tue, 15 Mar 2016 18:47:41 +0100 Subject: [PATCH 1/2] pickle: sync Python 2.7 stubs with Python 3 version The Python 3 version was added in 94467be. --- stdlib/2.7/pickle.pyi | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/stdlib/2.7/pickle.pyi b/stdlib/2.7/pickle.pyi index 1e47e0219..1b5b1d6f3 100644 --- a/stdlib/2.7/pickle.pyi +++ b/stdlib/2.7/pickle.pyi @@ -1,8 +1,38 @@ # Stubs for pickle (Python 2) -from typing import Any, IO +from typing import Any, BinaryIO -def dump(obj: Any, file: IO[str], protocol: int = ...) -> None: ... -def dumps(obj: Any, protocol: int = ...) -> str: ... -def load(file: IO[str]) -> Any: ... -def loads(str: str) -> Any: ... + +HIGHEST_PROTOCOL = ... # type: int + + +def dump(obj: Any, file: BinaryIO, protocol: int = None) -> None: ... +def dumps(obj: Any, protocol: int = ...) -> bytes: ... +def load(file: BinaryIO) -> Any: ... +def loads(string: bytes) -> Any: ... + + +class PickleError(Exception): + pass + + +class PicklingError(PickleError): + pass + + +class UnpicklingError(PickleError): + pass + + +class Pickler: + def __init__(self, file: BinaryIO, protocol: int = None) -> None: ... + + def dump(self, obj: Any) -> None: ... + + def clear_memo(self) -> None: ... + + +class Unpickler: + def __init__(self, file: BinaryIO) -> None: ... + + def load(self) -> Any: ... From c3a2b26ce259f468666c77823d39e36767fe0dd5 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Tue, 15 Mar 2016 19:11:15 +0100 Subject: [PATCH 2/2] cPickle: complete Python 2 stubs --- stdlib/2.7/cPickle.pyi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stdlib/2.7/cPickle.pyi b/stdlib/2.7/cPickle.pyi index 583cb8be2..fb129d1b5 100644 --- a/stdlib/2.7/cPickle.pyi +++ b/stdlib/2.7/cPickle.pyi @@ -7,10 +7,19 @@ format_version = ... # type: str class Pickler: def __init__(self, file: IO[str], protocol: int = ...) -> None: ... + def dump(self, obj: Any) -> None: ... + + def clear_memo(self) -> None: ... + class Unpickler: def __init__(self, file: IO[str]) -> None: ... + def load(self) -> Any: ... + + def noload(self) -> Any: ... + + def dump(obj: Any, file: IO[str], protocol: int = ...) -> None: ... def dumps(obj: Any, protocol: int = ...) -> str: ... def load(file: IO[str]) -> Any: ...