]> granicus.if.org Git - python/commitdiff
Fix the windows buildbot permission error - close the fd of tempfile beffore unlinking
authorSenthil Kumaran <senthil@uthcode.com>
Tue, 23 Oct 2012 18:07:02 +0000 (11:07 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Tue, 23 Oct 2012 18:07:02 +0000 (11:07 -0700)
Lib/test/test_urllib.py

index 2eac4e3cec22c203f42f3738196ec11a054ea86e..d8c3512fa850aa1f0e32a448aedb3064e135fad5 100644 (file)
@@ -278,12 +278,13 @@ Content-Type: text/html; charset=iso-8859-1
     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)