win32: close file when leaving _getfileinfo() stable
authorPatrick Mezard <pmezard@gmail.com>
Fri, 08 Jan 2010 23:15:22 +0100
branchstable
changeset 10219 3b94120864fc
parent 10218 750b7a4f01f6
child 10220 500d09be7ace
win32: close file when leaving _getfileinfo()
mercurial/win32.py
--- a/mercurial/win32.py	Fri Jan 08 18:48:39 2010 +0530
+++ b/mercurial/win32.py	Fri Jan 08 23:15:22 2010 +0100
@@ -43,9 +43,10 @@
         fh = win32file.CreateFile(pathname,
             win32file.GENERIC_READ, win32file.FILE_SHARE_READ,
             None, win32file.OPEN_EXISTING, 0, None)
-        res = win32file.GetFileInformationByHandle(fh)
-        fh.Close()
-        return res
+        try:
+            return win32file.GetFileInformationByHandle(fh)
+        finally:
+            fh.Close()
     except pywintypes.error:
         return None