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