Serhiy Storchaka <storchaka+cpyt...@gmail.com> 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, especially in implementations without reference counting. 
Since file descriptors are limited resource, this can cause troubles in real 
programs.

Reasons for close() in iterparse objects are the same as for close in files and 
generators.

Maybe we will need to implement the full generator protocol (send() and 
throw()) in the iterparse objects, but currently I do not know use cases for 
this.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25707>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to