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 scoder
Recipients abarry, scoder, serhiy.storchaka
Date 2019-05-02.08:32:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556785939.9.0.406189554748.issue25707@roundup.psfhosted.org>
In-reply-to
Content
Ok, I think it's reasonable to make the resource management explicit for the specific case of letting iterparse() open the file. That suggests that there should also be context manager support, given that safe usages would often involve a try-finally.

Since it might not always be obvious for users when they need to close the iterator or not, I would also suggest to not let it raise an error on a double-close, i.e. if .close() was already called or the iterator was already exhausted (and the file closed automatically), calling .close() should just do nothing.
History
Date User Action Args
2019-05-02 08:32:19scodersetrecipients: + scoder, serhiy.storchaka, abarry
2019-05-02 08:32:19scodersetmessageid: <1556785939.9.0.406189554748.issue25707@roundup.psfhosted.org>
2019-05-02 08:32:19scoderlinkissue25707 messages
2019-05-02 08:32:19scodercreate