# HG changeset patch # User Patrick Mezard # Date 2010-01-08 22:15:22 # Node ID 3b94120864fc2a1d421c5024dea11cf265ef949e # Parent 750b7a4f01f6c80b342620c976f1f58d5d188987 win32: close file when leaving _getfileinfo() diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -43,9 +43,10 @@ def _getfileinfo(pathname): 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