Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-69893: Add the close() method for xml.etree.ElementTree.iterparse() iterator#114534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-69893: Add the close() method for xml.etree.ElementTree.iterparse() iterator#114534
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Lib/test/test_xml_etree.py Outdated
@@ -608,6 +619,7 @@ def test_iterparse(self): | |||
iterparse(SIMPLE_XMLFILE, events) | |||
self.assertEqual(str(cm.exception), "unknown event 'bogus'") | |||
del cm | |||
gc_collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The addedgc_collect()
calls are redundant because thecheck_no_resource_warning()
context manager already callsgc_collect()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nice. The initial version of my patch predatescheck_no_resource_warning()
.
def __del__(self): | ||
# TODO: Emit a ResourceWarning if it was not explicitly closed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Any plans for when this TODO will be done? They can end up languishing for decades :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
When all maintained Python versions have theclose()
method, so you can call it without checking the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks!
Uh oh!
There was an error while loading.Please reload this page.
📚 Documentation preview 📚:https://cpython-previews--114534.org.readthedocs.build/