[Python-checkins] cpython: Fix the windows buildbot permission error - close the fd of tempfile beffore
senthil.kumaran
python-checkins at python.org
Tue Oct 23 20:07:13 CEST 2012
http://hg.python.org/cpython/rev/8576bf1c0302
changeset: 79919:8576bf1c0302
user: Senthil Kumaran <senthil at uthcode.com>
date: Tue Oct 23 11:07:02 2012 -0700
summary:
Fix the windows buildbot permission error - close the fd of tempfile beffore unlinking
files:
Lib/test/test_urllib.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -278,12 +278,13 @@
def test_file_notexists(self):
fd, tmp_file = tempfile.mkstemp()
tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
-
- self.assertTrue(os.path.exists(tmp_file))
- with urlopen(tmp_fileurl) as fobj:
- self.assertTrue(fobj)
-
- os.unlink(tmp_file)
+ try:
+ self.assertTrue(os.path.exists(tmp_file))
+ with urlopen(tmp_fileurl) as fobj:
+ self.assertTrue(fobj)
+ finally:
+ os.close(fd)
+ os.unlink(tmp_file)
self.assertFalse(os.path.exists(tmp_file))
with self.assertRaises(urllib.error.URLError):
urlopen(tmp_fileurl)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list