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: (c)elementTree missing children
Type: behavior Stage:
Components: Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, vkuznet
Priority: normal Keywords:

Created on 2010-09-27 12:25 by vkuznet, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
em_bug.tar vkuznet, 2010-09-27 12:25 tar ball with test code and test xml
Messages (2)
msg117440 - (view) Author: Valentin Kuznetsov (vkuznet) Date: 2010-09-27 12:25
Hi, I found that parsing XML file with identical structure leads to missing children item at some point. In my test case which I attach it happens at id=183. Basically I have XML with bunch of elements of the following structure:

<processed_dataset id='0'>
        <path dataset_path='/aaa/0'/>
</processed_dataset>
<processed_dataset id='1'>
        <path dataset_path='/aaa/0'/>
</processed_dataset>
....

when I parse them recursively, all, except the one with id=183, are parsed identically. The one with id=183 does not contain children. I tried the code with python 2.6 and python 2.7 on Mac and Linux. Bug exists in both version of ElementTree and cElementTree. Code and testbed XML are attached. Please untar and run as python test_bug.py.
Thanks,
Valentin
msg117441 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-09-27 12:54
The given script yields an item on a "start" event; but the element may not be fully populated at this point. please read http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse

You should use the "end" events instead.
History
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 54167
2010-09-27 12:54:41amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg117441

resolution: not a bug
2010-09-27 12:25:43vkuznetcreate