[Lxml-checkins] r45944 - lxml/trunk/src/lxml

scoder at codespeak.net scoder at codespeak.net
Fri Aug 24 10:33:06 CEST 2007


Author: scoder
Date: Fri Aug 24 10:33:05 2007
New Revision: 45944

Modified:
   lxml/trunk/src/lxml/etree.pyx
   lxml/trunk/src/lxml/proxy.pxi
Log:
another deallocation bug: order matters ...

Modified: lxml/trunk/src/lxml/etree.pyx
==============================================================================
--- lxml/trunk/src/lxml/etree.pyx	(original)
+++ lxml/trunk/src/lxml/etree.pyx	Fri Aug 24 10:33:05 2007
@@ -489,8 +489,9 @@
         #print "trying to free node:", <int>self._c_node
         #displayNode(self._c_node, 0)
         if self._c_node is not NULL:
-            unregisterProxy(self)
+            _unregisterProxy(self)
             attemptDeallocation(self._c_node)
+        _releaseProxy(self)
 
     # MANIPULATORS
 
@@ -1157,7 +1158,7 @@
         result = element_class()
     result._doc = doc
     result._c_node = c_node
-    registerProxy(result)
+    _registerProxy(result)
 
     if config.ENABLE_THREADING:
         python.PyThread_release_lock(ELEMENT_CREATION_LOCK)

Modified: lxml/trunk/src/lxml/proxy.pxi
==============================================================================
--- lxml/trunk/src/lxml/proxy.pxi	(original)
+++ lxml/trunk/src/lxml/proxy.pxi	Fri Aug 24 10:33:05 2007
@@ -16,7 +16,7 @@
 cdef int hasProxy(xmlNode* c_node):
     return c_node._private is not NULL
     
-cdef registerProxy(_Element proxy):
+cdef _registerProxy(_Element proxy):
     """Register a proxy and type for the node it's proxying for.
     """
     cdef xmlNode* c_node
@@ -31,14 +31,19 @@
     proxy._gc_doc = <python.PyObject*>proxy._doc
     python.Py_INCREF(proxy._doc)
 
-cdef unregisterProxy(_Element proxy):
+cdef _unregisterProxy(_Element proxy):
     """Unregister a proxy for the node it's proxying for.
     """
     cdef xmlNode* c_node
     c_node = proxy._c_node
     assert c_node._private is <void*>proxy, "Tried to unregister unknown proxy"
     c_node._private = NULL
-    python._Py_DECREF(proxy._gc_doc)
+
+cdef _releaseProxy(_Element proxy):
+    """An additional DECREF for the document.
+    """
+    if proxy._gc_doc is not NULL:
+        python._Py_DECREF(proxy._gc_doc)
 
 ################################################################################
 # temporarily make a node the root node of its document


More information about the lxml-checkins mailing list