Message110252
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. |
|
Date |
User |
Action |
Args |
2010-07-14 03:27:47 | eric-talevich | set | recipients:
+ eric-talevich |
2010-07-14 03:27:47 | eric-talevich | set | messageid: <1279078067.06.0.575324977312.issue9257@psf.upfronthosting.co.za> |
2010-07-14 03:27:45 | eric-talevich | link | issue9257 messages |
2010-07-14 03:27:45 | eric-talevich | create | |
|