[Python-checkins] CVS: python/dist/src/Lib weakref.py,1.4,1.5
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 28 Feb 2001 19:06:05 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv8774
Modified Files:
weakref.py
Log Message:
Change WeakDictionary to WeakValueDictionary in a couple more places.
WeakValueDictionary.copy(),
WeakKeyDictionary.copy(): Actually return the copy!
Index: weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** weakref.py 2001/02/27 18:36:55 1.4
--- weakref.py 2001/03/01 03:06:03 1.5
***************
*** 32,37 ****
# We inherit the constructor without worrying about the input
# dictionary; since it uses our .update() method, we get the right
! # checks (if the other dictionary is a WeakDictionary, objects are
! # unwrapped on the way out, and we always wrap on the way in).
def __getitem__(self, key):
--- 32,38 ----
# We inherit the constructor without worrying about the input
# dictionary; since it uses our .update() method, we get the right
! # checks (if the other dictionary is a WeakValueDictionary,
! # objects are unwrapped on the way out, and we always wrap on the
! # way in).
def __getitem__(self, key):
***************
*** 43,47 ****
def __repr__(self):
! return "<WeakDictionary at %s>" % id(self)
def __setitem__(self, key, value):
--- 44,48 ----
def __repr__(self):
! return "<WeakValueDictionary at %s>" % id(self)
def __setitem__(self, key, value):
***************
*** 51,59 ****
def copy(self):
! new = WeakDictionary()
for key, ref in self.data.items():
o = ref()
if o is not None:
new[key] = o
def get(self, key, default):
--- 52,61 ----
def copy(self):
! new = WeakValueDictionary()
for key, ref in self.data.items():
o = ref()
if o is not None:
new[key] = o
+ return new
def get(self, key, default):
***************
*** 140,143 ****
--- 142,146 ----
if o is not None:
new[o] = value
+ return new
def get(self, key, default):