[Python-checkins] r45900 - python/trunk/Lib/mailbox.py

"Martin v. Löwis" martin at v.loewis.de
Fri May 5 07:18:32 CEST 2006


Neal Norwitz wrote:
> Two questions, 1) shouldn't the class be:
> 
> class WindowsError(Exception): pass

For correctness, no: actual exceptions will never be of that class,
so the except clause will never match. While Python will enforce
some day that the exceptions raised inherit from exception, it won't
enforce that the exceptions caught inherit from exception - it
only requires that the names are bound. So in principle,

WindowsError = None

would have worked as well.

For clarity, it is certainly better to inherit from exception

> Does the ernno module exist on Windows and if so, do 2 and 183 exist in it?

It exists, but it (currently) doesn't define symbolic values for the
winerror.h constants. Perhaps it should.

> If not it might be easier to make your own local ENOTFOUND or whatever,
> then you wouldn't need comments.

I hesitate to define global things in a module if I don't mean them to
be imported (so I feel guilt about defining WindowsError as well).
Of course, _ERROR_FILE_NOT_FOUND would be harmless.

Regards,
Martin


More information about the Python-checkins mailing list