mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Merged revisions 77136 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77136 | ezio.melotti | 2009-12-30 08:14:51 +0200 (Wed, 30 Dec 2009) | 1 line #5511: Added the ability to use ZipFile as a context manager. Patch by Brian Curtin. ........
This commit is contained in:
parent
588009e934
commit
faa6b7f421
4 changed files with 458 additions and 477 deletions
|
|
@ -719,6 +719,12 @@ class ZipFile:
|
|||
self.fp = None
|
||||
raise RuntimeError('Mode must be "r", "w" or "a"')
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.close()
|
||||
|
||||
def _GetContents(self):
|
||||
"""Read the directory, making sure we close the file if the format
|
||||
is bad."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue