[Python-bugs-list] [ python-Bugs-738617 ] On Windows, os.listdir() throws incorrect exception
SourceForge.net
noreply@sourceforge.net
Thu, 15 May 2003 20:11:23 -0700
Bugs item #738617, was opened at 2003-05-16 13:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=738617&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Thompson (mikethompson)
Assigned to: Nobody/Anonymous (nobody)
Summary: On Windows, os.listdir() throws incorrect exception
Initial Comment:
ActivePython 2.2.2 Build 224 (ActiveState Corp.) based
on
Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import os
>>> os.listdir('c:\IMPOSSIBLE')
Traceback (most recent call last):
File "<stdin>", line 2, in ?
WindowsError: [Errno 3] The system cannot find the
path specified:
'c:\IMPOSSIBLE/*.*'
This is the wrong exception I would have thought.
AIUI, WindowsError is thrown for uniquely Windows
types of problems. Path not found is not unique to
Windows.
I would have expected an os.error exception to have
been thrown together with an code of errno.ENOENT.
This is what happens if I try to open() a non existent file.
(Caution: I'm a python newbie and I could easily have
missed something here -- If so sorry to waste your time)
The deadly part about this bug is that WindowsError
subclasses os.error, just the code changes (3 instead of
2). So my "except os.error" worked to catch the
exception ... just the error code seemed wrong. Took
be ages to figure it all out.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=738617&group_id=5470