Mailing List Archive

[issue2892] improve cElementTree iterparse error handling
New submission from Hrvoje Nikšić <hniksic@gmail.com>:

In some cases it is unfortunate that any error in the XML chunk seen by
the buffer prevents the events generated before the error from being
delivered. For example, in some cases valid XML is embedded in a larger
file or stream, and it is useful to be able to ignore text that follows
the root tag, if any.

The iterparse API and expat itself make this possible, but it doesn't
work because in case of a parsing exception, iterparse doesn't deliver
the events generated before the exception. A simple change to iterparse
makes this possible, however. I would like to share the change with you
for possible inclusion in a future release. Note that this change
shouldn't affect the semantics of iterparse: the exception is still
delivered to the caller, the only difference is that the events
generated by expat before the exception are not forgotten.

I am attaching a diff between the current implementation of iterparse,
and a modified one that fixes this problem.

----------
components: Extension Modules
files: patch
messages: 66935
nosy: hniksic
severity: normal
status: open
title: improve cElementTree iterparse error handling
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10343/patch

__________________________________
Tracker <report@bugs.python.org>
<http://bugs.python.org/issue2892>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue2892] improve cElementTree iterparse error handling [ In reply to ]
Changes by Georg Brandl <georg@python.org>:


----------
assignee: -> effbot
nosy: +effbot

__________________________________
Tracker <report@bugs.python.org>
<http://bugs.python.org/issue2892>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com