[issue15775] Add StopParser() to expat

2012-08-24 Thread Nemeskey Dávid

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: XML
messages: 168980
nosy: nemeskeyd
priority: normal
severity: normal
status: open
title: Add StopParser() to expat
type: enhancement

___
Python tracker 
<http://bugs.python.org/issue15775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15775] Add StopParser() to expat

2012-08-28 Thread Nemeskey Dávid

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 
<http://bugs.python.org/issue15775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15775] Add StopParser() to expat

2012-08-28 Thread Nemeskey Dávid

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 
<http://bugs.python.org/issue15775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15775] Add StopParser() to expat

2012-09-06 Thread Nemeskey Dávid

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 
way for flow control (at least this is the policy in other languages e.g. Java, 
I don't know about Python).

--

___
Python tracker 
<http://bugs.python.org/issue15775>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com