Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,11 @@ os._wrap_close.write # Methods that come from __getattr__() at runtime
os._wrap_close.writelines # Methods that come from __getattr__() at runtime
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem

_pickle.Pickler.reducer_override # Can be added by subclasses
pickle.Pickler.reducer_override # Can be added by subclasses
pickle._Pickler\..* # Best effort typing for undocumented internals
pickle._Unpickler\..* # Best effort typing for undocumented internals

shutil.rmtree # function with attributes, which we approximate with a callable protocol
socketserver.BaseServer.get_request # Not implemented, but expected to exist on subclasses.
ssl.PROTOCOL_SSLv2 # Depends on the existence and flags of SSL
Expand Down
5 changes: 4 additions & 1 deletion stdlib/_pickle.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class PicklerMemoProxy:
class Pickler:
fast: bool
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
reducer_override: Callable[[Any], Any]
bin: bool # undocumented
def __init__(
self,
Expand All @@ -79,6 +78,10 @@ class Pickler:

# this method has no default implementation for Python < 3.13
def persistent_id(self, obj: Any, /) -> Any: ...
# The following method is not defined on _Pickler, but can be defined on
# sub-classes. Should return `NotImplemented` if pickling the supplied
# object is not supported and returns the same types as `__reduce__()`.
def reducer_override(self, obj: object, /) -> _ReducedType: ...

@type_check_only
class UnpicklerMemoProxy:
Expand Down
5 changes: 4 additions & 1 deletion stdlib/pickle.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class _Pickler:
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
bin: bool # undocumented
dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]] # undocumented, _Pickler only
reducer_override: Callable[[Any], Any]
def __init__(
self,
file: SupportsWrite[bytes],
Expand All @@ -220,6 +219,10 @@ class _Pickler:
def dump(self, obj: Any) -> None: ...
def clear_memo(self) -> None: ...
def persistent_id(self, obj: Any) -> Any: ...
# The following method is not defined on _Pickler, but can be defined on
# sub-classes. Should return `NotImplemented` if pickling the supplied
# object is not supported and returns the same types as `__reduce__()`.
def reducer_override(self, obj: object, /) -> _ReducedType: ...
Comment on lines +222 to +225
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done for _pickler.Pickler (aka the public pickle.Pickler) as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done.


class _Unpickler:
dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]] # undocumented, _Unpickler only
Expand Down
Loading