[XML-SIG] DOM and xmlproc problem

Jeff.Johnson@stn.siemens.com Jeff.Johnson@stn.siemens.com
Fri, 9 Oct 1998 16:28:31 -0400


I don't know much about the various XML parsers but I think I have found a
circular reference in at least one.  When I call the following code...
     p = saxexts.make_parser()
     p = None
...the object pointed to by 'p' does not get freed.  I know this becuase I
modified the __init__ and __del__ functions for class SAX_XPParser in
xml.sax.drivers.drv_xmlproc to print "INIT" and "DEL".  "DEL" never prints
but "INIT" does.

I tried to find out why it doesn't get freed but got lost in all the code.
I was hoping someone that knows this code would take a look.  I don't know
if this will affect all users since some people may have different XML
parsers than I do.  I run in windows and have no idea if pyexpat is being
used on my machine, nor do I know how to properly debug Python, I just use
a lot of print statements :)

DOM:
The DOM tree doesn't get freed because the parser points to the builder via
"doc_handler", the builder points to the document and to the
current_element which also points to the document.

To get it to the DOM to free you must either call:
     builder.document = None
     builder.current_element = None
or call:
     parser.setDocumentHandler(None)

The second method is better because it also frees the builder.

That's about as far as I can take it, anyone up for finding the circular
reference in the parser?

Cheers,
Jeff