Skip to content

gh-155324: Pickle frozendict with all protocols - #155325

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:frozendict-pickle-parity
Open

gh-155324: Pickle frozendict with all protocols#155325
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:frozendict-pickle-parity

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

frozendict only defined __getnewargs__, so pickling raised TypeError at
protocols 0 and 1 (which do not use it); protocols 2 to 5 worked. Give
frozendict a __reduce__ mirroring frozenset, so it pickles at every
protocol, including a subclass's instance state.

frozendict only defined __getnewargs__, so pickling raised TypeError at
protocols 0 and 1. Give it a __reduce__ mirroring frozenset.
@aisk

aisk commented Aug 7, 2026

Copy link
Copy Markdown
Member

Lib/test/pickletester.py has some tests for frozendict pickling. They specify minprotocol=2 because frozendict didn't support protocols 0 and 1 before. Since this PR adds support for them, we should update these tests to also run under protocols 0 and 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants