[Zodb-checkins] SVN: ZODB/branches/3.3/ Port from ZODB 3.2.
Tim Peters
tim.one at comcast.net
Thu Feb 24 15:07:29 EST 2005
Log message for revision 29286:
Port from ZODB 3.2.
Note that cPickleCache.c must be recompiled else the new test will fail.
Change the exception raised when an attempt is made to add two objects to
the cache with the same oid. The former messsage didn't make sense.
Add a test to verify that this exception does get raised, and that the
message given is the intended one.
This is the first of a series of checkins, to fix critical bugs where
ZODB can in fact raise this exception in rare, but normal, use cases.
Changed:
U ZODB/branches/3.3/NEWS.txt
U ZODB/branches/3.3/src/ZODB/tests/testCache.py
U ZODB/branches/3.3/src/persistent/cPickleCache.c
-=-
Modified: ZODB/branches/3.3/NEWS.txt
===================================================================
--- ZODB/branches/3.3/NEWS.txt 2005-02-24 17:37:16 UTC (rev 29285)
+++ ZODB/branches/3.3/NEWS.txt 2005-02-24 20:07:29 UTC (rev 29286)
@@ -28,7 +28,22 @@
depending on platform, and should suffer far fewer (if any) intermittent
"timed out waiting for storage to connect" failures.
+Pickle (in-memory Connection) Cache
+-----------------------------------
+You probably never saw this exception:
+
+ ``ValueError: Can not re-register object under a different oid``
+
+It's been changed to say what it meant:
+
+ ``ValueError: A different object already has the same oid``
+
+This happens if an attempt is made to add distinct objects to the cache
+that have the same oid (object identifier). ZODB should never do this,
+but it's possible for application code to force such an attempt.
+
+
What's new in ZODB3 3.3.1a1?
============================
Release date: 11-Jan-2005
Modified: ZODB/branches/3.3/src/ZODB/tests/testCache.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/tests/testCache.py 2005-02-24 17:37:16 UTC (rev 29285)
+++ ZODB/branches/3.3/src/ZODB/tests/testCache.py 2005-02-24 20:07:29 UTC (rev 29286)
@@ -398,6 +398,28 @@
else:
self.fail("expect that you can't delete jar of cached object")
+ def checkTwoObjsSameOid(self):
+ # Try to add two distinct objects with the same oid to the cache.
+ # This has always been an error, but the error message prior to
+ # ZODB 3.2.6 didn't make sense. This test verifies that (a) an
+ # exception is raised; and, (b) the error message is the intended
+ # one.
+ obj1 = StubObject()
+ key = obj1._p_oid = p64(1)
+ obj1._p_jar = self.jar
+ self.cache[key] = obj1
+
+ obj2 = StubObject()
+ obj2._p_oid = key
+ obj2._p_jar = self.jar
+ try:
+ self.cache[key] = obj2
+ except ValueError, detail:
+ self.assertEqual(str(detail),
+ "A different object already has the same oid")
+ else:
+ self.fail("two objects with the same oid should have failed")
+
def test_suite():
s = unittest.makeSuite(DBMethods, 'check')
s.addTest(unittest.makeSuite(LRUCacheTests, 'check'))
Modified: ZODB/branches/3.3/src/persistent/cPickleCache.c
===================================================================
--- ZODB/branches/3.3/src/persistent/cPickleCache.c 2005-02-24 17:37:16 UTC (rev 29285)
+++ ZODB/branches/3.3/src/persistent/cPickleCache.c 2005-02-24 20:07:29 UTC (rev 29286)
@@ -901,7 +901,7 @@
if (object_again) {
if (object_again != v) {
PyErr_SetString(PyExc_ValueError,
- "Can not re-register object under a different oid");
+ "A different object already has the same oid");
return -1;
} else {
/* re-register under the same oid - no work needed */
More information about the Zodb-checkins
mailing list