New submission from Serhiy Storchaka: 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'> 34 Martin Panter proposed in issue25688 to add an explicit way to clean it up, like a generator.close() method. ---------- assignee: serhiy.storchaka components: Library (Lib) messages: 255159 nosy: serhiy.storchaka priority: normal severity: normal stage: needs patch status: open title: Add the close method for ElementTree.iterparse() object type: resource usage versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25707> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com