Just van Rossum wrote:
Greg Ewing wrote:
Barry Warsaw wrote:
One possible approach is to revert BaseException out of Py2.5, re-position KeyboardInterrupt, and add Error as an alias for StandardError. Then we can encourage people to start using Error as the base classes for their own errors.
Also maybe start issuing warnings whenever you inherit directly from Exception.
Ugh. I hate it when it's made (virtually) impossible to write code that runs warnings-free on both Python X.Y and X.(Y+1).
This was one of the key things that led to the approach in PEP 352. Barry's hierarchy is very similar to some of the suggestions made during the PEP 348 discussion, and they were rejected because they made the transition a hell of a lot harder without any concomitant benefit. I know this because I was one of the people making those suggestions.
With PEP 352 (tweaked to move GeneratorExit out from under Exception): - "except:" continues to mean catch everything - "except Exception:" now does the right thing - inheriting from Exception continues to be correct for user exceptions - errors may choose to inherit from one of the existing Errors instead
With Barry's proposed hierarchy: - "except:" continues to mean catch everything - "except Exception:" continues to do the wrong thing - all code has to change to do "except Error:" instead - inheriting from Exception becomes incorrect for user exceptions - all code has to change to inherit from Error instead - non-error user exceptions (such as completion of a search using nested loops) have no clear parent to inherit from (both Error and Exception are wrong, albeit for different reasons.
The additional pain required in order to have 'Exception' at the root of the hierarchy just isn't worth it.