[issue9846] ZipExtFile provides no mechanism for closing the underlying file object

Antoine Pitrou report at bugs.python.org
Tue Sep 14 14:45:17 CEST 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

> Antoine, any reason not to put the close in the ZipFileExt close method 
> instead of a __del__ method?  (And document it, of course).

You are right, a close() method would be enough.
Furthermore, ZipExtFile already supports the context manager protocol (implicitly calling BufferedIOBase.close()), so you will simply be able to write:

with myzipfile.open("README", "r") as f:
    # ...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9846>
_______________________________________


More information about the Python-bugs-list mailing list