Parse an XML document from a URL or an InputSource.
(self, source)
| 93 | # XMLReader methods |
| 94 | |
| 95 | def parse(self, source): |
| 96 | "Parse an XML document from a URL or an InputSource." |
| 97 | source = saxutils.prepare_input_source(source) |
| 98 | |
| 99 | self._source = source |
| 100 | try: |
| 101 | self.reset() |
| 102 | self._cont_handler.setDocumentLocator(ExpatLocator(self)) |
| 103 | xmlreader.IncrementalParser.parse(self, source) |
| 104 | except: |
| 105 | # bpo-30264: Close the source on error to not leak resources: |
| 106 | # xml.sax.parse() doesn't give access to the underlying parser |
| 107 | # to the caller |
| 108 | self._close_source() |
| 109 | raise |
| 110 | |
| 111 | def prepareParser(self, source): |
| 112 | if source.getSystemId() is not None: |
no test coverage detected