start banging on zipfile's file leakiness

This commit is contained in:
Benjamin Peterson 2010-10-31 17:57:22 +00:00
parent d6868b4ed4
commit d285bdb443
2 changed files with 50 additions and 10 deletions

View file

@ -874,7 +874,8 @@ class ZipFile:
def read(self, name, pwd=None):
"""Return file bytes (as a string) for name."""
return self.open(name, "r", pwd).read()
with self.open(name, "r", pwd) as fp:
return fp.read()
def open(self, name, mode="r", pwd=None):
"""Return file-like object for 'name'."""