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.

Author eric-talevich
Recipients eric-talevich
Date 2010-07-14.03:27:44
SpamBayes Score 6.830183e-05
Marked as misclassified No
Message-id <1279078067.06.0.575324977312.issue9257@psf.upfronthosting.co.za>
In-reply-to
Content
In xml.etree, ElementTree and cElementTree implement different interfaces for the iterparse function/class.

In ElementTree, the argument "events" must be a tuple of strings:

from xml.etree import ElementTree as ET
for result in ET.iterparse('example.xml', events=('start', 'end')):
    print(result)

That works, given a valid XML file 'example.xml'. If the event names are given as bytes instead of strings (b'start', b'end'), there's no crash, but no events are recognized.

In cElementTree, it's the opposite: the events argument must be a tuple of bytes:

from xml.etree import cElementTree as cET
for result in cET.iterparse('example.xml', events=(b'start', b'end')):
    print(result)

Giving a tuple of strings instead of bytes results in:

>>> for result in cET.iterparse('example.xml', events=('start', 'end')):
...     print(result)
TypeError: invalid event tuple


This makes it difficult to use ElementTree as a backup for cElementTree, or at least very awkward.
History
Date User Action Args
2010-07-14 03:27:47eric-talevichsetrecipients: + eric-talevich
2010-07-14 03:27:47eric-talevichsetmessageid: <1279078067.06.0.575324977312.issue9257@psf.upfronthosting.co.za>
2010-07-14 03:27:45eric-talevichlinkissue9257 messages
2010-07-14 03:27:45eric-talevichcreate