summaryrefslogtreecommitdiffstats
path: root/Lib/weakref.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r--Lib/weakref.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 6663c26..0276dfd 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -85,6 +85,17 @@ class WeakValueDictionary(collections.MutableMapping):
new[key] = o
return new
+ __copy__ = copy
+
+ def __deepcopy__(self, memo):
+ from copy import deepcopy
+ new = self.__class__()
+ for key, wr in self.data.items():
+ o = wr()
+ if o is not None:
+ new[deepcopy(key, memo)] = o
+ return new
+
def get(self, key, default=None):
try:
wr = self.data[key]
@@ -251,6 +262,17 @@ class WeakKeyDictionary(collections.MutableMapping):
new[o] = value
return new
+ __copy__ = copy
+
+ def __deepcopy__(self, memo):
+ from copy import deepcopy
+ new = self.__class__()
+ for key, value in self.data.items():
+ o = key()
+ if o is not None:
+ new[o] = deepcopy(value, memo)
+ return new
+
def get(self, key, default=None):
return self.data.get(ref(key),default)