Movatterモバイル変換
[0]ホーム
[Python-Dev] PEP,take 2: Exception Reorganization for Python 3.0
Guido van Rossumgvanrossum at gmail.com
Thu Aug 4 01:19:18 CEST 2005
[Guido van Rossum]> > OK, I'm changing my mind again about the names again.> >> > Exception as the root and StandardError can stay; the only new> > proposal would then be to make bare 'except:' call StandardError.[James Y Knight]> I don't see how that can work. Any solution that is expected to> result in a usable hierarchy this century must preserve "Exception"> as the object that user exceptions should derive from (and therefore> that users should generally catch, as well). There is way too much> momentum behind that to change it.This is actually a good point, and what I was thinking when I firstresponded to Brett.Sorry for the waivering -- being at OSCON always is a serious attackon my system.I'm still searching for a solution that lets us call everything in thehierarchy "exception" and *yet* has Exception at the mid-point in thathierarchy where Brett has StandardException. The problem with Raisableis that it doesn't contain the word exception; perhaps we can call itBaseException? We've got a few more things called base-such-and-such,e.g. basestring (not that I like that one all that much).BTW I just noticed UserException -- shouldn't this be UserError?Also... We should have a guideline for when to use "...Exception" andwhen to use "...Error". Maybe we can use ...Exception for the firsttwo levels of the hierarchy, ...Error for errors, and other endingsfor things that aren't errors (like SystemExit)? Then the top of thetree would look like this:BaseException (or RootException?)+-- CriticalException+-- ControlFlowException+-- Exception +-- (all regular exceptions start here) +-- WarningAll common errors and warnings derive from Exception; bare 'except:' would be the same as 'except Exception:'. (I like that particularlybecause I've been writing that in lots of code already. :-)A refinement might be to introduce something called Error, which wouldchange the last part of the avove hierarchy as follows:(first three lines same as above)+-- Exception +-- Error +-- (all regular ...Error exceptions start here) +-- Warning +-- (all warnings start here)This has a nice symmetry between Error and Warning.Downside is that this "breaks" all user code that currently tries tobe correct by declaring exceptions as deriving from Exception, whichis pretty common; they would have to derive from Error to bepolitically correct.I don't immediately see what's best -- maybe Exception and Errorshould be two names for the same object??? But that's ugly too as along-term solution.-- --Guido van Rossum (home page:http://www.python.org/~guido/)
More information about the Python-Devmailing list
[8]ページ先頭