[Python-checkins] r76642 - python/trunk/Lib/urllib.py
philip.jenvey
python-checkins at python.org
Thu Dec 3 03:40:13 CET 2009
Author: philip.jenvey
Date: Thu Dec 3 03:40:13 2009
New Revision: 76642
Log:
actually close files
Modified:
python/trunk/Lib/urllib.py
Modified: python/trunk/Lib/urllib.py
==============================================================================
--- python/trunk/Lib/urllib.py (original)
+++ python/trunk/Lib/urllib.py Thu Dec 3 03:40:13 2009
@@ -231,7 +231,7 @@
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 @@
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 @@
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")
More information about the Python-checkins
mailing list