diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-12-03 02:40:13 (GMT) |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-12-03 02:40:13 (GMT) |
commit | 0299d0d7f03653400a563e69d6d2e062cf47320a (patch) | |
tree | 66399b3f0c59934b237ffb3f59c4c8c00bf53807 /Lib | |
parent | 2627553afa7347610ab0e061573112042854fd09 (diff) | |
download | cpython-0299d0d7f03653400a563e69d6d2e062cf47320a.zip cpython-0299d0d7f03653400a563e69d6d2e062cf47320a.tar.gz cpython-0299d0d7f03653400a563e69d6d2e062cf47320a.tar.bz2 |
actually close files
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/urllib.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index db8e616..1c31d48 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -231,7 +231,7 @@ class URLopener: try: fp = self.open_local_file(url1) hdrs = fp.info() - del fp + fp.close() return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass @@ -275,8 +275,6 @@ class URLopener: tfp.close() finally: fp.close() - del fp - del tfp # raise exception if actual size does not match content-length header if size >= 0 and read < size: @@ -1570,9 +1568,8 @@ def test(args=[]): print '======' for k in h.keys(): print k + ':', h[k] print '======' - fp = open(fn, 'rb') - data = fp.read() - del fp + with open(fn, 'rb') as fp: + data = fp.read() if '\r' in data: table = string.maketrans("", "") data = data.translate(table, "\r") |