[Zodb-checkins] CVS: ZODB3/Persistence - cPersistence.c:1.72.8.17
Jeremy Hylton
jeremy at zope.com
Tue Jul 8 10:54:50 EDT 2003
Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv31758/Persistence
Modified Files:
Tag: zodb33-devel-branch
cPersistence.c
Log Message:
Enable GC for Persistent objects, but don't do anything in tp_clear.
XXX If we really end up with a no-op tp_clear, we don't need to have
one.
=== ZODB3/Persistence/cPersistence.c 1.72.8.16 => 1.72.8.17 ===
--- ZODB3/Persistence/cPersistence.c:1.72.8.16 Mon Jul 7 14:11:17 2003
+++ ZODB3/Persistence/cPersistence.c Tue Jul 8 09:54:43 2003
@@ -126,6 +126,7 @@
ghostify(cPersistentObject *self)
{
PyObject **dictptr;
+
/* are we already a ghost? */
if (self->state == cPersistent_GHOST_STATE)
return;
@@ -411,14 +412,13 @@
static int
Per_clear(cPersistentObject *self)
{
- /* XXX Will subtype_clear() handle the instance dict? */
- ghostify(self);
- Py_XDECREF(self->jar);
- Py_XDECREF(self->oid);
- Py_XDECREF(self->cache);
- self->jar = NULL;
- self->oid = NULL;
- self->cache = NULL;
+ /* Don't do anything!
+
+ Any cycle involving a persistent object must also involve the cache.
+ If we clear the object now, the ghostify() code will fail to remove
+ it from the cache. The cache's tp_clear slot will ghostify this
+ object, so that should be safe.
+ */
return 0;
}
@@ -595,7 +595,7 @@
{
int deactivate = 0, true;
if (!v) {
- /* delattr is used to invalidate an object *even* if it has changed. */
+ /* delattr is used to invalidate an object even if it has changed. */
if (self->state != cPersistent_GHOST_STATE)
self->state = cPersistent_UPTODATE_STATE;
deactivate = 1;
@@ -790,7 +790,7 @@
(getattrofunc)Per_getattro, /* tp_getattro */
(setattrofunc)Per_setattro, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
/* tp_flags */
0, /* tp_doc */
(traverseproc)Per_traverse, /* tp_traverse */
@@ -800,7 +800,7 @@
0, /* tp_iter */
0, /* tp_iternext */
Per_methods, /* tp_methods */
- 0, /* tp_members */
+ 0, /* tp_members */
Per_getsets, /* tp_getset */
};
More information about the Zodb-checkins
mailing list