Skip to content

frozendict cannot be pickled with protocols 0 and 1 #155324

Description

@tonghuaroot

Bug report

frozendict cannot be pickled with protocols 0 and 1, while frozenset can:

>>> import pickle
>>> pickle.dumps(frozendict(a=1), 0)
Traceback (most recent call last):
  ...
TypeError: cannot pickle 'frozendict' object
>>> pickle.dumps(frozenset({1}), 0)  # works

Protocols 2 through 5 already work. frozendict only defines __getnewargs__,
a protocol-2-and-later mechanism, while frozenset defines __reduce__, which
works at every protocol.

CPython versions tested on:

3.16 (main)

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions