You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The copy module will not properly copy/deepcopy weakrefs, it will bomb
out with __new__ not having enough args. This is a problem b/c it makes
deepcopying of objects that make use of Weak(Key|Value)Dictionaries
difficult.
Rick: In the future, please provide a context or unified diff ("diff
-c") so that we get the file name that the diff is for and some
additional context.
Activity
rharris commentedon Feb 14, 2008
The copy module will not properly copy/deepcopy weakrefs, it will bomb
out with __new__ not having enough args. This is a problem b/c it makes
deepcopying of objects that make use of Weak(Key|Value)Dictionaries
difficult.
To replicate:
jafo commentedon Mar 19, 2008
Rick: In the future, please provide a context or unified diff ("diff
-c") so that we get the file name that the diff is for and some
additional context.
rharris commentedon Apr 4, 2008
Sorry about forgetting the -c arg! The patch is intended for
python/trunk/Lib/copy.py.
It looks like Raymond Hettinger has made a similar-ish change recently
to make Ellipsis copyable.
pitrou commentedon Mar 14, 2009
Should a deepcopy of a weakref return the same weakref, or a weakref to
a new copied object?
Also, what about the optional callback?
pitrou commentedon Mar 14, 2009
Hmm, forget that question. If we deepcopy the weakref target, it will be
destroyed just afterwards, making the deepcopied weakref useless.
pitrou commentedon Mar 15, 2009
Here is a patch providing proper copy and deepcopy support, including
for weak dicts (the Proxy type is unsupported, though).
pitrou commentedon Mar 15, 2009
Updated patch so that copied weakdicts are decoupled (adding an item to
the copy doesn't mutate the original).
pitrou commentedon May 1, 2009
Raymond, Guido, any opinion on this one?
pitrou commentedon May 15, 2009
Committed in r72662, r72670. Thanks!