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: ElementTree iterparse documentation
Type: behavior Stage: resolved
Components: Documentation, XML Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Peter.Harris, docs@python, eli.bendersky, python-dev, scoder
Priority: normal Keywords:

Created on 2013-10-30 13:57 by Peter.Harris, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg201734 - (view) Author: Peter Harris (Peter.Harris) Date: 2013-10-30 13:57
Documentation on python website says:

    xml.etree.ElementTree.iterparse(source, events=None, parser=None)
Parses an XML section into an element tree incrementally, and reports what’s going on to the user. source is a filename or file object containing XML data. events is a list of events to report back.

But 'events' must be a *tuple* or iterparse raises "TypeError: invalid event tuple"

Possibly also worth explaining that "start-ns" event is accompanied by a tuple of (namespace, url) rather than an element from the XML document. Currently the description just says "ns events are used to get detailed namespace information" but doesn't say how or give an example.
msg201746 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2013-10-30 16:41
How about actually allowing a list in addition to a tuple? And, in fact, any sequence? I can't see a reason not to.

For reference, lxml only expects it to be either None or an iterable. Essentially, I consider it more of a set-like filter, since the linear aspect of a tuple/list/sequence has no meaning for it.
msg201756 - (view) Author: Peter Harris (Peter.Harris) Date: 2013-10-30 18:20
Yeah it would make sense to accept any iterable, but I'm only proposing a documentation fix not a feature enhancement.
msg201810 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-10-31 12:51
Thanks for the report, Peter. This is indeed a documentation fix for Python 3.3; note that in 3.4 (default branch), the restriction was lifted and iterparse now accepts any iterable sequence. The documentation also reflects that (saying that 'events' is a sequence).

I'll update the 3.3 docs to address this issue.
msg201811 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-31 12:55
New changeset e6941225e014 by Eli Bendersky in branch '3.3':
Issue #19452: Clarify the documentation of iterparse w.r.t. events argument.
http://hg.python.org/cpython/rev/e6941225e014

New changeset 2a996cecf762 by Eli Bendersky in branch 'default':
Null merge for issue #19452
http://hg.python.org/cpython/rev/2a996cecf762
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63651
2013-10-31 12:56:10eli.benderskysetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2013-10-31 12:55:46python-devsetnosy: + python-dev
messages: + msg201811
2013-10-31 12:51:11eli.benderskysetstage: needs patch
2013-10-31 12:51:01eli.benderskysetmessages: + msg201810
2013-10-30 18:20:23Peter.Harrissetmessages: + msg201756
2013-10-30 16:41:13scodersetnosy: + eli.bendersky, scoder
messages: + msg201746

components: + XML
type: behavior
2013-10-30 13:57:26Peter.Harriscreate