posixfile_nt: set closed early
authorMatt Mackall <mpm@selenic.com>
Fri, 11 Jan 2008 14:06:05 -0600
changeset 5840 c67dfc4ecba6
parent 5839 59fba5caa94b
child 5841 07ca22a72dcc
posixfile_nt: set closed early Exceptions in __init__ may leave us with close undefined in __del__
mercurial/util_win32.py
--- a/mercurial/util_win32.py	Wed Jan 09 10:00:18 2008 -0600
+++ b/mercurial/util_win32.py	Fri Jan 11 14:06:05 2008 -0600
@@ -227,6 +227,9 @@
     # but does not work at all. wrap win32 file api instead.
 
     def __init__(self, name, mode='rb'):
+        self.closed = False
+        self.name = name
+        self.mode = mode
         access = 0
         if 'r' in mode or '+' in mode:
             access |= win32file.GENERIC_READ
@@ -250,9 +253,6 @@
                                                0)
         except pywintypes.error, err:
             raise WinIOError(err, name)
-        self.closed = False
-        self.name = name
-        self.mode = mode
 
     def __iter__(self):
         for line in self.read().splitlines(True):