Skip to content

gh-162644: Raise TypeError when pickling a weakref.ref subclass with protocol 0 or 1 - #162728

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-162644-weakref-subclass
Nov 27, 2026
Merged

serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-162644-weakref-subclass

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Previously it caused infinite recursion: copyreg._reduce_ex() used base(self) as the state, and for a weakref.ref subclass it is a new weak reference to the object being pickled. Now it raises TypeError, as with other protocols.

🤖 Generated with Claude Code

… with protocol 0 or 1

Previously it caused infinite recursion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant