Re: [xml] Support for Python

On Mon, 28 Jan 2002, Dave Kuhlman wrote:

_But_, I worry about code like the following:

doc = p.xmlParseFile('test1.xml')
root = doc.children
doc = p.xmlParseFile('test1.xml')

Now, root contains a reference to a Python object that contains a
reference to an underlying C object (a libxml node) that has gone
away.  Am I right about this?  If so it seems very dangerous. 
xmlFreeDoc frees the nodes in the doc, too, doesn't it?

Hmmm, if xmlNodes in doc.children have references to the parent (ie the 
xmlDoc) then this _should_ work -- the first doc won't be garbage 
collected because root.parent is referencing it. On the other hand, it 
might have created an undeletable object.

Ick! I expect the best way to resolve what happens here would be a bit of 
good old printf() debugging :)


[ gary inauspicious org ][ GnuPG 85A8F78B ][ ]

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