summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-31 17:57:22 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-10-31 17:57:22 (GMT)
commitd285bdb4434a57126f7f17dc6b8f78204c180c1f (patch)
tree00790aae4b9fbe0f54af017ac415cce34eea97ef /Lib/zipfile.py
parentd6868b4ed45617675151d5abda7acf0080df8ca5 (diff)
downloadcpython-d285bdb4434a57126f7f17dc6b8f78204c180c1f.zip
cpython-d285bdb4434a57126f7f17dc6b8f78204c180c1f.tar.gz
cpython-d285bdb4434a57126f7f17dc6b8f78204c180c1f.tar.bz2
start banging on zipfile's file leakiness
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index a51dd21..184f4d2 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -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'."""