diff options
author | Paul Prescod <prescod@prescod.net> | 2000-07-01 04:58:47 (GMT) |
---|---|---|
committer | Paul Prescod <prescod@prescod.net> | 2000-07-01 04:58:47 (GMT) |
commit | 73678dac48e5858e40cba6d526970cba7e7c769c (patch) | |
tree | 9cb93c23e4a2cd4a881e86694f8204e33c2ed106 /Lib/xml/dom/pulldom.py | |
parent | 8fcaa92c5f4290c0ea31f2680c87635bc751303f (diff) | |
download | cpython-73678dac48e5858e40cba6d526970cba7e7c769c.zip cpython-73678dac48e5858e40cba6d526970cba7e7c769c.tar.gz cpython-73678dac48e5858e40cba6d526970cba7e7c769c.tar.bz2 |
Reference cycle fixes
Diffstat (limited to 'Lib/xml/dom/pulldom.py')
-rw-r--r-- | Lib/xml/dom/pulldom.py | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py index 9c85646..0c047f6 100644 --- a/Lib/xml/dom/pulldom.py +++ b/Lib/xml/dom/pulldom.py @@ -2,7 +2,6 @@ import minidom import types import string import sys -import pyexpat from xml.sax import ExpatParser #todo: SAX2/namespace handling @@ -140,12 +139,8 @@ class DOMEventStream: if cur_node is node: return if token !=END_ELEMENT: - cur_node.parentNode.childNodes.append( cur_node ) + cur_node.parentNode.appendChild( cur_node ) event=self.getEvent() - if node.nodeType==minidom.Node.DOCUMENT_NODE: - for child in node.childNodes: - if child.nodeType==minidom.Node.ELEMENT_NODE: - node.documentElement=child def getEvent( self ): if not self.pulldom.firstEvent[1]: @@ -193,75 +188,7 @@ def parseString( string, parser=None ): stringio=StringIO.StringIO bufsize=len( string ) - stringio( string ) + buf=stringio( string ) parser=_getParser() return DOMEventStream( buf, parser, bufsize ) -#FIXME: Use Lars' instead!!! -class SAX_expat: - "SAX driver for the Pyexpat C module." - - def __init__(self): - self.parser=pyexpat.ParserCreate() - self.started=0 - - def setDocumentHandler( self, handler ): - self.parser.StartElementHandler = handler.startElement - self.parser.EndElementHandler = handler.endElement - self.parser.CharacterDataHandler = handler.datachars - self.parser.ProcessingInstructionHandler = handler.processingInstruction - self.doc_handler=handler - - def setErrorHandler( self, handler ): - self.err_handler=handler - - # --- Locator methods. Only usable after errors. - - def getLineNumber(self): - return self.parser.ErrorLineNumber - - def getColumnNumber(self): - return self.parser.ErrorColumnNumber - - # --- Internal - - def __report_error(self): - msg=pyexpat.ErrorString(self.parser.ErrorCode) - self.err_handler.fatalError(msg) - - # --- EXPERIMENTAL PYTHON SAX EXTENSIONS - - def get_parser_name(self): - return "pyexpat" - - def get_parser_version(self): - return "Unknown" - - def get_driver_version(self): - return version - - def is_validating(self): - return 0 - - def is_dtd_reading(self): - return 0 - - def reset(self): - self.parser=pyexpat.ParserCreate() - self.parser.StartElementHandler = self.startElement - self.parser.EndElementHandler = self.endElement - self.parser.CharacterDataHandler = self.characters - self.parser.ProcessingInstructionHandler = self.processingInstruction - - def feed(self,data): - if not self.started: - self.doc_handler.startDocument() - self.started=1 - if not self.parser.Parse(data): - self.__report_error() - - def close(self): - if not self.parser.Parse("",1): - self.__report_error() - self.doc_handler.endDocument() - self.parser = None |