Commit 1b1b18d7 authored by Tim Peters's avatar Tim Peters

Merge rev 29286 from ZODB 3.3 branch.

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.
parent bfd6c670
......@@ -81,6 +81,21 @@ make a connection. The ZEO reconnection tests may run much faster now,
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?
============================
......
......@@ -398,6 +398,28 @@ class CacheErrors(unittest.TestCase):
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'))
......
......@@ -901,7 +901,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment