This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Propagate all errors from ElementTree.iterparse
Type: behavior Stage: resolved
Components: Extension Modules, XML Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, martin.panter, python-dev, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-12-06 15:00 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
etree_propagate_errors.patch serhiy.storchaka, 2015-12-06 15:00 review
Messages (3)
msg256012 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-06 15:00
Some memory errors raised in handlers during XML parsing are explicitly or implicitly propagated to the caller of XMLParser methods feed(), close(), and _parse_whole(). But others are silenced with PyErr_Clear() with added comments "FIXME: propagate error". There are no reasons why one errors are propagated and others are not. For example memory error during creating tuple is not propagated, but memory error during resizing a list to which this tuple is appended is propagated. Looks as this is not intentional.

Not propagated errors can cause the lost of events. Proposed patch makes the parser to propagate all errors. Since it extracts common code into the treebuilder_append_event() function and inlines the treebuilder_handle_namespace() function, the resulting code becomes even simpler, its size is decreased by 49 lines.
msg256031 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-06 21:30
The patch looks good as far as I can tell. I left a question about an inconsistency with checking for a null pointer.
msg256035 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-12-06 22:13
New changeset 2df330606cd0 by Serhiy Storchaka in branch '3.4':
Issue25814: Propagate all errors from custom XML parser handlers
https://hg.python.org/cpython/rev/2df330606cd0

New changeset de9ef294a3ef by Serhiy Storchaka in branch '2.7':
Issue25814: Propagate all errors from custom XML parser handlers
https://hg.python.org/cpython/rev/de9ef294a3ef

New changeset 0d1bbfe8fd09 by Serhiy Storchaka in branch '3.5':
Issue25814: Propagate all errors from custom XML parser handlers
https://hg.python.org/cpython/rev/0d1bbfe8fd09

New changeset 2cf16918b632 by Serhiy Storchaka in branch 'default':
Issue25814: Propagate all errors from custom XML parser handlers
https://hg.python.org/cpython/rev/2cf16918b632
History
Date User Action Args
2022-04-11 14:58:24adminsetgithub: 70000
2015-12-07 00:32:44serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-12-06 22:13:49python-devsetnosy: + python-dev
messages: + msg256035
2015-12-06 21:30:02martin.pantersetnosy: + martin.panter
messages: + msg256031
2015-12-06 15:01:51serhiy.storchakalinkissue25638 dependencies
2015-12-06 15:00:03serhiy.storchakacreate