[Python-Dev] GeneratorExit inheriting from Exception (original) (raw)
Barry Warsaw barry at python.org
Mon Mar 20 16:39:04 CET 2006
- Previous message: [Python-Dev] GeneratorExit inheriting from Exception
- Next message: [Python-Dev] GeneratorExit inheriting from Exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 2006-03-19 at 17:31 +1000, Nick Coghlan wrote:
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.
One quibble. Since the term used for the general concept of something that is raised and caught is "exception" and since all the raise-able objects live in a module called "exceptions", it is confusing that "except Exception" will not catch all exceptions.
-Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20060320/1ac1cdde/attachment.pgp
- Previous message: [Python-Dev] GeneratorExit inheriting from Exception
- Next message: [Python-Dev] GeneratorExit inheriting from Exception
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]