[Zodb-checkins] CVS: Zope2/lib/python/ZODB - PersistentMapping.py:1.9

chrism@serenade.digicool.com chrism@serenade.digicool.com
Tue, 5 Jun 2001 14:45:33 -0400


Update of /cvs-repository/Zope2/lib/python/ZODB
In directory serenade:/home/chrism/sandboxes/Post24BugFixing/lib/python/ZODB

Modified Files:
	PersistentMapping.py 
Log Message:
made keys() method return a *copy* of the cached keys list, preventing mutations of the cached keys list that could cause later problems.  (Collector 2283).


--- Updated File PersistentMapping.py in package Zope2/lib/python/ZODB --
--- PersistentMapping.py	2000/04/21 20:06:34	1.8
+++ PersistentMapping.py	2001/06/05 18:45:33	1.9
@@ -140,7 +140,7 @@
         return map(lambda k, d=self: (k,d[k]), self.keys())
 
     def keys(self):
-        try: return self._v_keys
+        try: return list(self._v_keys) # return a copy (Collector 2283)
         except: pass
         keys=self._v_keys=filter(
             lambda k: not isinstance(k,types.StringType) or k[:1]!='_',
@@ -151,6 +151,8 @@
     def update(self, b):
         a=self._container
         for k, v in b.items(): a[k] = v
+        try: del self._v_keys
+        except: pass
         self._p_changed=1
 
     def values(self):