[Python-Dev] "DOS" error codes, WindowsError, and errno
"Martin v. Löwis"
martin at v.loewis.de
Tue Jan 31 07:46:26 CET 2006
Guido van Rossum wrote:
> WindowsError should have used a different name for the Windows-native
> error code, so we could have defined both separately without
> confusion.
>
> Is it too late to change WindowsError in that way?
We could define a different exception, say, Win32Error which inherits
from OSError, and has a POSIX errno in the errno attribute, and also
an additional attribute win32_error. We could then stop raising
WindowsError. So code that expects WindowsError will never see it, but
will see OSError instead (which it also should handle if it was written
portable).
Or we could just break the errno value in WindowsError, which would
make code that catches WindowsError continue to work, but break
code that looks for specific errno values in WindowsError. Code aiming
for backwards compatibility should then write
except WindowsError, e:
try:
windows_error = e.windows_error
except NameError:
# Python 2.4 and earlier
windows_error = e.errno
As for naming, I would like to avoid naming new things Win32: Microsoft
just changed the name of the API to "Windows API" (pointing out that
it isn't necessarily 32 bits anymore).
Regards,
Martin
More information about the Python-Dev
mailing list