Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5982
| From | John Lee <jjl@pobox.com> |
|---|---|
| Subject | Re: List of WindowsError error codes and meanings |
| Date | 2011-05-22 17:55 +0000 |
| References | <mailman.1847.1305914213.9059.python-list@python.org> <8762p48eel.fsf@pobox.com> <ir8m4b$f16$3@dont-email.me> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1920.1306086918.9059.python-list@python.org> (permalink) |
Genstein <genstein <at> invalid.invalid> writes:
>
> > Andrew Berg<bahamutzero8825 <at> gmail.com> writes:
> > Since Python 2.5, the errno attribute maps the Windows error to error
> > codes that match the attributes of module errno.
>
> Good point, I completely misread that. At least the Windows error code
> is still available as the winerror attribute.
>
> As an aside - call me stupid, but I don't quite follow the purpose of
> that errno mapping. Surely if the error number can be mapped
> successfully then the error isn't Windows specific and an OSError should
> logically be thrown instead? And if it can't be mapped successfully then
> errno will never be valid so the mapping is pointless?
Since WindowsError is a subclass of OSError, .errno has to be there (and it must
contain the UNIXy error code). You could then ask why it's a subclass in the
first place. I think part of the answer is that the docs are wrong --
presumably actual usage is that WindowsError is raised when a Windows API call
is made that *may* result in an exception that has no corresponding errno value
("presumably" because I'm writing on Linux & sourceforge is too slow for me
today to grab pywin32). In other words, code that raises WindowsError doesn't
try to test the error code so that it can raise OSError instead some of the
time. I don't think there would be any benefit in doing that, and it would have
the disadvantage that with those calls, you'd have to deal with a mixture of
Windows and UNIXy error codes.
The presence of .errno, aside from being required (to satisfy LSP), does mean
you don't have to deal with the Windows codes if you're only interested in cases
covered by module errno.
John
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 12:56 -0500
Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-20 20:47 +0100
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 16:55 -0500
Re: List of WindowsError error codes and meanings John J Lee <jjl@pobox.com> - 2011-05-21 12:46 +0100
Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-21 16:35 +0100
Re: List of WindowsError error codes and meanings John Lee <jjl@pobox.com> - 2011-05-22 17:55 +0000
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-22 09:35 -0500
Re: List of WindowsError error codes and meanings Thomas Heller <theller@ctypes.org> - 2011-05-26 17:02 +0200
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-27 04:22 -0500
csiph-web