[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeModuleTemplate.c:1.1.2.2

Jeremy Hylton jeremy@zope.com
Mon, 25 Feb 2002 14:26:16 -0500


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv318

Modified Files:
      Tag: Zope-3x-branch
	BTreeModuleTemplate.c 
Log Message:
Add an INCREF() in init_persist_type().

    /* The INCREF below is based on superstition.  I suspect that by
       marking an object as Py_TPFLAGS_HEAPTYPE, it is possible for
       the type to be collected by the GC.  This doesn't make any
       sense for a statically allocated type in an extension module,
       but HEAPTYPE is necessary for other reasons.  If this guess is
       right, then the INCREF below, which has no corresponding
       DECREF, will prevent collection.
     */



=== Zope3/lib/python/Persistence/BTrees/BTreeModuleTemplate.c 1.1.2.1 => 1.1.2.2 ===
     if (PyType_Ready(type) < 0)
 	return -1;
+    /* The INCREF below is based on superstition.  I suspect that by
+       marking an object as Py_TPFLAGS_HEAPTYPE, it is possible for
+       the type to be collected by the GC.  This doesn't make any
+       sense for a statically allocated type in an extension module,
+       but HEAPTYPE is necessary for other reasons.  If this guess is
+       right, then the INCREF below, which has no corresponding
+       DECREF, will prevent collection.
+     */
+    Py_INCREF(type);
 
     /* PyPersist_Type defines a tp_dictoffset so that classes that
        mixin Persistent can have an __dict__.  But this messes up the