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 serhiy.storchaka
Recipients serhiy.storchaka
Date 2015-11-23.13:57:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If ElementTree.iterparse() is called with file names, it opens a file. When resulting iterator is not exhausted, the file lefts not closed.

>>> import xml.etree.ElementTree as ET
>>> import gc
>>> ET.iterparse('/dev/null')
<xml.etree.ElementTree._IterParseIterator object at 0xb6f9e38c>
>>> gc.collect()
__main__:1: ResourceWarning: unclosed file <_io.BufferedReader name='/dev/null'>

Martin Panter proposed in issue25688 to add an explicit way to clean it up, like a generator.close() method.
Date User Action Args
2015-11-23 13:57:25serhiy.storchakasetrecipients: + serhiy.storchaka
2015-11-23 13:57:25serhiy.storchakasetmessageid: <>
2015-11-23 13:57:25serhiy.storchakalinkissue25707 messages
2015-11-23 13:57:25serhiy.storchakacreate