Windows exception handling overwrought?

Matt Mackall mpm at selenic.com
Tue Jun 23 19:27:11 CDT 2009


So we've recently had this issue filed:

http://mercurial.selenic.com/bts/issue1707

Looks like all the relevant bits are hiding in win32.py rather than
windows.py. But it also looks to me as if this code is wholly
unnecessary. According to the Python docs:

exception WindowsError
        
        Raised when a Windows-specific error occurs or when the error
        number does not correspond to an errno value. The winerror and
        strerror values are created from the return values of the
        GetLastError and FormatMessage functions from the Windows
        Platform API. The errno value maps the winerror value to
        corresponding errno.h values. This is a subclass of OSError.
        
So we don't actually need a big mapping of Windows errors to Unix
errors, as it's already being done for us.

We've also got exactly two users of this code: the posixfile wrapper in
windows.py (which should return an IOError) and os_link in win32.py (any
exception will do, really). As far as I can tell we can rip out
WinError, WinIOError, and WinOSError (120 lines of code) with no ill
effects. Am I missing something?

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list