gh-69893: Add the close() method for xml.etree.ElementTree.iterparse() iterator#114534
Merged
serhiy-storchaka merged 3 commits intopython:mainfrom Feb 4, 2024
Merged
Conversation
colesbury
reviewed
Jan 24, 2024
Lib/test/test_xml_etree.py
Outdated
| iterparse(SIMPLE_XMLFILE, events) | ||
| self.assertEqual(str(cm.exception), "unknown event 'bogus'") | ||
| del cm | ||
| gc_collect() |
Contributor
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().
Member
Author
There was a problem hiding this comment.
Nice. The initial version of my patch predates check_no_resource_warning().
hugovk
reviewed
Jan 26, 2024
| gen.close() | ||
|
|
||
| def __del__(self): | ||
| # TODO: Emit a ResourceWarning if it was not explicitly closed. |
Member
There was a problem hiding this comment.
Any plans for when this TODO will be done? They can end up languishing for decades :)
Member
Author
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.
Member
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.
hugovk
approved these changes
Jan 26, 2024
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
fsc-eriker
pushed a commit
to fsc-eriker/cpython
that referenced
this pull request
Feb 14, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 Documentation preview 📚: https://cpython-previews--114534.org.readthedocs.build/