Nemeskey Dávid added the comment:
Amaury: see my previous comment. There are two problems with the method you
proposed:
1. It is not mentioned in the documentation that exceptions are propagated
through parse().
2. Exceptions usually mean that an error has happened, and is not the preferred
Amaury Forgeot d'Arc added the comment:
Your first point is true, even if the Python zen (try import this)
states that Errors should never pass silently.
For your second point: exceptions are a common thing in Python code. This is
similar to the EAFP principle
Amaury Forgeot d'Arc added the comment:
Below is a sample script that shows that it's possible to stop parsing XML in
the middle, without an explicit call to XML_StopParser(): raise StopParsing
from any handler, and catch it around the Parse() call.
This method covers the two proposed use
Changes by Berker Peksag berker.pek...@gmail.com:
--
versions: +Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15775
___
___
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
Martin v. Löwis added the comment:
nemeskeyd: would you like to work on a patch (for Python 3.4)?
--
nosy: +loewis
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15775
___
Nemeskey Dávid added the comment:
loewis: I don't think it would be difficult to fix, so theoretically I'd be in.
However, I don't really have the time to work on this right now.
--
___
Python tracker rep...@bugs.python.org
Amaury Forgeot d'Arc added the comment:
If a handler function raises an exception, the Parse() method exits and the
exception is propagated; internally, this also calls XML_StopParser().
Why would one call XML_StopParser() explicitely?
--
nosy: +amaury.forgeotdarc
New submission from Nemeskey Dávid:
The C expat library provides XML_StopParser() method that allows the parsing to
be stopped from the handler functions. It would be nice to have this option in
Python as well, maybe by adding StopParser() method to the XMLParser class.
--
components: