[issue25707] Add the close method for ElementTree.iterparse() object

2022-03-05 Thread Jacob Walls
Change by Jacob Walls : -- keywords: +patch nosy: +jacobtylerwalls nosy_count: 4.0 -> 5.0 pull_requests: +29816 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/31696 ___ Python tracker

[issue25707] Add the close method for ElementTree.iterparse() object

2020-05-06 Thread Furkan Onder
Furkan Onder added the comment: Python 3.8.2 (default, Apr 8 2020, 14:31:25) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import xml.etree.ElementTree as ET >>> import gc >>> ET.iterparse('/dev/null') .IterParseIterator object at

[issue25707] Add the close method for ElementTree.iterparse() object

2019-05-02 Thread Stefan Behnel
Stefan Behnel added the comment: 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

[issue25707] Add the close method for ElementTree.iterparse() object

2019-05-02 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Implicit closing an exhausted iterator helps only the iterator is iterated to the end. If the iteration has been stopped before the end, we get a leak of the file descriptor. Closing the file descriptor in the finalizer can be deferred to undefined term,

[issue25707] Add the close method for ElementTree.iterparse() object

2019-04-27 Thread Stefan Behnel
Stefan Behnel added the comment: I don't think there is a need for a close() method. Instead, the iterator should close the file first thing when it's done with it, but only if it owns it. Therefore, the fix in issue 25688 seems correct. Closing can also be done explicitly in a finaliser of

[issue25707] Add the close method for ElementTree.iterparse() object

2015-11-26 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- dependencies: +Verify the etree_parse and etree_iterparse benchmarks are working appropriately ___ Python tracker

[issue25707] Add the close method for ElementTree.iterparse() object

2015-11-23 Thread Serhiy Storchaka
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') >>> gc.collect() __main__:1:

[issue25707] Add the close method for ElementTree.iterparse() object

2015-11-23 Thread Emanuel Barry
Emanuel Barry added the comment: I am unable to reproduce the issue on Windows 7 with 3.5.0; I have tried opening a small (non-empty) text. Here's the result: >>> import xml.etree.ElementTree as ET >>> import gc >>> ET.iterparse("E:/New.txt") >>> gc.collect() 59 -- nosy: +ebarry

[issue25707] Add the close method for ElementTree.iterparse() object

2015-11-23 Thread Emanuel Barry
Emanuel Barry added the comment: Oh, my bad. Ignore my last message, behaviour is identical then. Thanks for clearing that up. -- ___ Python tracker ___

[issue25707] Add the close method for ElementTree.iterparse() object

2015-11-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You have to enable deprecation warnings. Run the interpreter with the -Wa option. -- ___ Python tracker ___