← 输入框|github.com|刷新
Skip to content

[3.15] gh-162802: Forbid copying of weakref.WeakSet - #162803

Open
serhiy-storchaka wants to merge 1 commit into
python:3.15from
serhiy-storchaka:weakset-forbid-copy-3.15
Open

serhiy-storchaka wants to merge 1 commit into
python:3.15from
serhiy-storchaka:weakset-forbid-copy-3.15

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

copy.copy() and copy.deepcopy() of weakref.WeakSet created broken copies which shared internal state with the original. Now they raise TypeError, as pickling already does. The WeakSet.copy() method can be used instead.

This is for 3.15 and 3.14 only. In 3.16, copying was fixed as part of gh-74876.

🤖 Generated with Claude Code

copy.copy() and copy.deepcopy() of WeakSet created broken copies
which shared internal state with the original.
Now they raise TypeError.  Use the copy() method instead.
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.

1 participant