Re: [xml] How do I detect node identity in the Python bindings?

On Thu, Jun 17, 2004 at 11:35:00AM -0400, Victor Ng wrote:
How do I get the same reference for a node in libxml2?

The Python wrappers and the PyCObject have different references, so I 
can't seem to find a safe way to deallocate memory.

Here's a snippet to show the problem:

 >>> import libxml2
 >>> doc = libxml2.newDoc('1.0')
 >>> root = doc.newChild(None, 'root', None)
 >>> print root, doc.children <xmlNode (root) object at 0x419c60> 
<xmlNode (root) object at 0x4710d0>
 >>> print root._o, doc.children._o
<PyCObject object at 0x221d0> <PyCObject object at 0x22170>

Is this a bug in libxml2's Python bindings or does libxml2 exhibit this 
behavior when I use the native C bindings?

  That's a problem in the python bindings, the objects are the same at the
C level but the wrapper creates new objects. an extra function to test
the underlying C node equality would be needed.


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]