[Python-bugs-list] [ python-Bugs-812050 ] Inconsistent exceptions
raised (OSError/IOError)
SourceForge.net
noreply at sourceforge.net
Wed Sep 24 17:42:10 EDT 2003
Bugs item #812050, was opened at 2003-09-24 17:24
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=812050&group_id=5470
Category: None
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Nobody/Anonymous (nobody)
Summary: Inconsistent exceptions raised (OSError/IOError)
Initial Comment:
It seems odd that functions seem to randomly choose
which they'll raise. Example:
>>> import os
>>> os.stat("I don't exist.")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 2] No such file or directory: "I don't
exist."
>>> file("I don't exist.")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: "I don't
exist."
>>> isinstance(OSError, IOError)
False
>>> isinstance(IOError, OSError)
False
>>> issubclass(OSError, IOError)
False
>>> issubclass(IOError, OSError)
False
For backwards compatibility, it's probably hard to
change the actual exception raised, but shouldn't
IOError be a subclass of OSError?
----------------------------------------------------------------------
>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-09-24 17:42
Message:
Logged In: YES
user_id=12800
In programs where it matters, use EnvironmentError, which is
the common superclass of OSError and IOError.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=812050&group_id=5470
More information about the Python-bugs-list
mailing list