[Python-checkins] CVS: python/dist/src/Lib UserDict.py,1.15,1.16

Fred L. Drake fdrake@users.sourceforge.net
2001年11月05日 09:40:50 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv11352
Modified Files:
	UserDict.py 
Log Message:
copy(): Make sure the copy of a derived class cannot share the data of the
original by replacing self.data temporarily, then using the update() method
on the new mapping object to populate it.
This closes SF bug #476616.
Index: UserDict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserDict.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** UserDict.py	2001年08月07日 17:40:42	1.15
--- UserDict.py	2001年11月05日 17:40:48	1.16
***************
*** 20,24 ****
 return UserDict(self.data)
 import copy
! return copy.copy(self)
 def keys(self): return self.data.keys()
 def items(self): return self.data.items()
--- 20,31 ----
 return UserDict(self.data)
 import copy
! data = self.data
! try:
! self.data = {}
! c = copy.copy(self)
! finally:
! self.data = data
! c.update(self)
! return c
 def keys(self): return self.data.keys()
 def items(self): return self.data.items()

AltStyle によって変換されたページ (->オリジナル) /