[Zope3-checkins] CVS: ZODB/src/ZODB/tests - testCache.py:1.24
Tim Peters
tim.one at comcast.net
Fri May 7 15:11:01 EDT 2004
Update of /cvs-repository/ZODB/src/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv21371/src/ZODB/tests
Modified Files:
testCache.py
Log Message:
Collector 1309: ZODB.DB.DB.cacheExtremeDetail reports wrong reference count
The refcount reported for a ghost was one too small, because the code for
ghosts and non-ghosts was the same, and presumably "it's a feature" that
the code for non-ghosts deliberately lies about the true Python refcount,
in order (guessing here) to report what the count would have been if the
cPickleCache didn't exist. But while the cPickleCache holds on to a real
reference to non-ghost objects, it does not hold a real reference to ghost
objects, so subtracting "an extra" count for all objects made it appear
that non-referenced ghosts exist in the cache (which doesn't actually
happen).
What a tangled web we weave ...
=== ZODB/src/ZODB/tests/testCache.py 1.23 => 1.24 ===
--- ZODB/src/ZODB/tests/testCache.py:1.23 Mon Apr 19 17:19:07 2004
+++ ZODB/src/ZODB/tests/testCache.py Fri May 7 15:11:00 2004
@@ -205,7 +205,7 @@
# XXX The above gc.collect call is necessary to make this test
# pass.
#
- # This test then only works because the other of computations
+ # This test then only works because the order of computations
# and object accesses in the "noodle" calls is such that the
# persistent mapping containing the MinPO objects is
# deactivated before the MinPO objects.
@@ -230,12 +230,15 @@
self.assertEqual(count, CONNS)
for details in self.db.cacheExtremeDetail():
- # one dict per object. keys:
+ # one 'details' dict per object
if details['klass'].endswith('PersistentMapping'):
self.assertEqual(details['state'], None)
else:
self.assert_(details['klass'].endswith('MinPO'))
self.assertEqual(details['state'], 0)
+ # The cache should never hold an unreferenced ghost.
+ if details['state'] is None: # i.e., it's a ghost
+ self.assert_(details['rc'] > 0)
class StubDataManager:
def setklassstate(self, object):
More information about the Zope3-Checkins
mailing list