[issue15775] Add StopParser() to expat

Nemeskey Dávid report at bugs.python.org
Tue Aug 28 10:17:05 CEST 2012


Nemeskey Dávid added the comment:

OK, then this issue has a "bug" part, too: it is not mentioned in the documentation that exceptions from the handler methods propagate through the Parse() method. I guess the parser can be then stopped in this way too, but it is a dirty method as opposed to calling StopParser().

To answer your question, there are several situations where StopParser() could come in handy. For instance, the XML file might contain records (such as the output of a search engine), from which we only need the first n. Another example would be that reading through the file we realize halfway that e.g. it does not contain the information we need, contains wrong information, etc. so we want to skip the rest of it. Since the file might be huge and since XML parsing can in now way be considered fast, being able to stop the parsing in a clear way would spare the superfluous and possible lengthy computation.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15775>
_______________________________________


More information about the Python-bugs-list mailing list