[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0
James Y Knight
foom at fuhm.net
Sun Jul 31 18:12:06 CEST 2005
On Jul 30, 2005, at 8:57 PM, Nick Coghlan wrote:
> I wouldn't mind using Exception/Error instead of Raisable/Exception
> - and it
> seriously reduces the pain of making this transition. Indeed, most
> of it
> becomes doable within the 2.x series - the only tricky parts are
> semantic
> changes involved with moving the KeyboardInterrupt, MemoryError and
> SystemError out from under StandardError, and moving EOFError under
> IOError.
It seems to me that it *increases* the pain of transition.
I do not see any reason why adding a new class above the current
hierarchy causes any problems. However, changing the recommended base
class for user-defined exceptions from "Exception" to "Error" will
cause problems for *every* library.
Moving KeyboardInterrupt, MemoryError, and SystemError out from under
Exception will be a backwards compatibility issue, but that's the
case in all proposals. Additionally, I predict the pain from doing
that will be minor. In cases where apps want to catch *all*
exceptions, they must already use "except:" instead of "except
Exception:", as not all exceptions derive from Exception. And
catching the above three in any circumstance other than when
explicitly mentioned and when wanting to catch every exception is
probably wrong. So moving them will probably not cause many programs
to malfunction.
I think the following could be done in Py2.5:
a) add Raisable above Exception
b) move KeyboardInterrupt, MemoryError, and SystemError somewhere
under Raisable but not under Exception
c) pending deprecation warning for "except:" and raising objects that
aren't subclasses of "Raisable".
d) (not really related, but while I'm at it...) Allow exceptions
derived from object (with Raisable too, of course)
For Py2.6:
a) change pending deprecation warning above to deprecation warning.
James
More information about the Python-Dev
mailing list