[Python-Dev] WindowsError repr

Mark Hammond MarkH@ActiveState.com
Tue, 15 Aug 2000 10:46:56 +1000


I have just checked in a fix for: [ Bug #110670 ] Win32 os.listdir raises
confusing errors
http://sourceforge.net/bugs/?group_id=5470&func=detailbug&bug_id=110670

In a nutshell:
>>> os.listdir('/cow')
...
OSError: [Errno 3] No such process: '/cow'
>>>

The solution here was to use the new WindowsError object that was defined
back in February
(http://www.python.org/pipermail/python-dev/2000-February/008803.html)  As
this is a sub-class of OSError, nothing will break.

However, the _look_ of the error does change.  After my fix, it now looks
like:

>>> os.listdir('/cow')
...
WindowsError: [Errno 3] The system cannot find the path specified: '/cow'
>>>

AGAIN - I stress - catching "OSError" or "os.error" _will_ continue to
work, as WindowsError derives from OSError.  It just worries me that people
will start explicitly catching "WindowsError", regardless of whatever
documentation we might write on the subject.

Does anyone see this as a problem?  Should a WindowsError masquerade as
"OSError", or maybe just look a little more like it - eg, "OSError
(windows)" ??

Thoughts,

Mark.