Uh oh!
There was an error while loading. Please reload this page.
gh-69893: Add the close() method for xml.etree.ElementTree.iterparse() iterator - #114534
Conversation
| iterparse(SIMPLE_XMLFILE, events) | ||
| self.assertEqual(str(cm.exception), "unknown event 'bogus'") | ||
| del cm | ||
| gc_collect() |
There was a problem hiding this comment.
The added gc_collect() calls are redundant because the check_no_resource_warning() context manager already calls gc_collect().
There was a problem hiding this comment.
Nice. The initial version of my patch predates check_no_resource_warning().
| gen.close() | ||
| def __del__(self): | ||
| # TODO: Emit a ResourceWarning if it was not explicitly closed. |
There was a problem hiding this comment.
Any plans for when this TODO will be done? They can end up languishing for decades :)
There was a problem hiding this comment.
When all maintained Python versions have the close() method, so you can call it without checking the version.
There was a problem hiding this comment.
Maybe update the TODO to mention this, so when someone sees it they know whether they can do the TODO or wait a bit longer?
Anyway, I'll approve this.
Uh oh!
There was an error while loading. Please reload this page.
📚 Documentation preview 📚: https://cpython-previews--114534.org.readthedocs.build/