changeset 10219:3b94120864fc stable

win32: close file when leaving _getfileinfo()
author Patrick Mezard <pmezard@gmail.com>
date Fri, 08 Jan 2010 23:15:22 +0100
parents 750b7a4f01f6
children 500d09be7ace
files mercurial/win32.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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