mercurial/win32.py
changeset 8328 91f1fe78454c
parent 8227 0a9542703300
child 8329 79a12651d46b
--- a/mercurial/win32.py	Thu Mar 26 13:12:11 2009 -0700
+++ b/mercurial/win32.py	Thu Mar 26 13:13:48 2009 -0700
@@ -131,9 +131,15 @@
         }
 
     def __init__(self, err):
-        self.win_errno, self.win_function, self.win_strerror = err
-        if self.win_strerror.endswith('.'):
-            self.win_strerror = self.win_strerror[:-1]
+        try:
+            # unpack a pywintypes.error tuple
+            self.win_errno, self.win_function, self.win_strerror = err
+        except ValueError:
+            # get attributes from a WindowsError
+            self.win_errno = err.winerror
+            self.win_function = None
+            self.win_strerror = err.strerror
+        self.win_strerror = self.win_strerror.rstrip('.')
 
 class WinIOError(WinError, IOError):
     def __init__(self, err, filename=None):