[Python-checkins] CVS: python/dist/src/Lib UserDict.py,1.15,1.16
Fred L. Drake
fdrake@users.sourceforge.net
Mon, 05 Nov 2001 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()