@@ -31,8 +31,9 @@ class WeakValueDictionary(UserDict.UserDict):
3131
3232 # We inherit the constructor without worrying about the input
3333 # dictionary; since it uses our .update() method, we get the right
34- # checks (if the other dictionary is a WeakDictionary, objects are
35- # unwrapped on the way out, and we always wrap on the way in).
34+ # checks (if the other dictionary is a WeakValueDictionary,
35+ # objects are unwrapped on the way out, and we always wrap on the
36+ # way in).
3637
3738 def __getitem__ (self , key ):
3839 o = self .data .get (key )()
@@ -42,19 +43,20 @@ def __getitem__(self, key):
4243 return o
4344
4445 def __repr__ (self ):
45- return "<WeakDictionary at %s>" % id (self )
46+ return "<WeakValueDictionary at %s>" % id (self )
4647
4748 def __setitem__ (self , key , value ):
4849 def remove (o , data = self .data , key = key ):
4950 del data [key ]
5051 self .data [key ] = ref (value , remove )
5152
5253 def copy (self ):
53- new = WeakDictionary ()
54+ new = WeakValueDictionary ()
5455 for key , ref in self .data .items ():
5556 o = ref ()
5657 if o is not None :
5758 new [key ] = o
59+ return new
5860
5961 def get (self , key , default ):
6062 try :
@@ -139,6 +141,7 @@ def copy(self):
139141 o = key ()
140142 if o is not None :
141143 new [o ] = value
144+ return new
142145
143146 def get (self , key , default ):
144147 return self .data .get (ref (key ),default )
0 commit comments