diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index d2d31ee8ef53..73bc3da9eb6e 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -295,3 +295,9 @@ typing_extensions\.Annotated # Undocumented implementation details # (Remove once 3.10.17 becomes available for all platforms) (email._header_value_parser.get_encoded_word)? (email._header_value_parser.make_quoted_pairs)? + +# These methods have no default implementation for Python < 3.13. +_pickle.Pickler.persistent_id +_pickle.Unpickler.persistent_load +pickle.Pickler.persistent_id +pickle.Unpickler.persistent_load diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index 92a7543862d7..655e603c06d1 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -259,3 +259,9 @@ typing_extensions\.Annotated # Undocumented implementation details # (Remove once 3.11.12 becomes available for all platforms) (email._header_value_parser.get_encoded_word)? (email._header_value_parser.make_quoted_pairs)? + +# These methods have no default implementation for Python < 3.13. +_pickle.Pickler.persistent_id +_pickle.Unpickler.persistent_load +pickle.Pickler.persistent_id +pickle.Unpickler.persistent_load diff --git a/stdlib/@tests/stubtest_allowlists/py312.txt b/stdlib/@tests/stubtest_allowlists/py312.txt index aaea7009760b..3222fed0d8aa 100644 --- a/stdlib/@tests/stubtest_allowlists/py312.txt +++ b/stdlib/@tests/stubtest_allowlists/py312.txt @@ -228,3 +228,9 @@ sunau.Au_write.initfp threading.Lock # Factory function at runtime, but that wouldn't let us use it in type hints types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature typing_extensions\.Annotated # Undocumented implementation details + +# These methods have no default implementation for Python < 3.13. +_pickle.Pickler.persistent_id +_pickle.Unpickler.persistent_load +pickle.Pickler.persistent_id +pickle.Unpickler.persistent_load diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 04e9978a1ed6..a912b6f85b5b 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -245,3 +245,9 @@ typing_extensions\.Annotated # Undocumented implementation details # Incompatible changes introduced in Python 3.9.22 # (Remove once 3.9.22 becomes available for all platforms) (email._header_value_parser.get_encoded_word)? + +# These methods have no default implementation for Python < 3.13. +_pickle.Pickler.persistent_id +_pickle.Unpickler.persistent_load +pickle.Pickler.persistent_id +pickle.Unpickler.persistent_load diff --git a/stdlib/_pickle.pyi b/stdlib/_pickle.pyi index 50bbb6bc16cd..8e8afb600efa 100644 --- a/stdlib/_pickle.pyi +++ b/stdlib/_pickle.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import ReadableBuffer, SupportsWrite from collections.abc import Callable, Iterable, Iterator, Mapping from pickle import PickleBuffer as PickleBuffer @@ -75,10 +74,9 @@ class Pickler: def memo(self, value: PicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ... def dump(self, obj: Any, /) -> None: ... def clear_memo(self) -> None: ... - if sys.version_info >= (3, 13): - def persistent_id(self, obj: Any, /) -> Any: ... - else: - persistent_id: Callable[[Any], Any] + + # this method has no default implementation for Python < 3.13 + def persistent_id(self, obj: Any, /) -> Any: ... @type_check_only class UnpicklerMemoProxy: @@ -101,7 +99,6 @@ class Unpickler: def memo(self, value: UnpicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ... def load(self) -> Any: ... def find_class(self, module_name: str, global_name: str, /) -> Any: ... - if sys.version_info >= (3, 13): - def persistent_load(self, pid: Any, /) -> Any: ... - else: - persistent_load: Callable[[Any], Any] + + # this method has no default implementation for Python < 3.13 + def persistent_load(self, pid: Any, /) -> Any: ...