Movatterモバイル変換
[0]ホーム
[Python-Dev] PEP 348: Exception Reorganization for Python 3.0
Raymond Hettingerraymond.hettinger at verizon.net
Fri Aug 5 20:46:41 CEST 2005
The PEP moves StopIteration out from under Exception so that it cannotbe caught by a bare except or an explicit "except Exception".IMO, this is a mistake. In either form, a programmer is stating thatthey want to catch and handle just about anything. There is areasonable argument that SystemExit special and should float to the top,but that is not the case with StopIteration.When a user creates their own exception for exiting multiple levels ofloops or frames, should they inherit from ControlFlowException on thetheory that it no different in intent from StopIteration or should theyinherit from UserError on the theory that it is a custom exception? Doyou really want routine control-flow exceptions to bypass "exceptException". I suspect that will lead to coding errors that are verydifficult to spot (it sure looks like it should catch a StopIteration).Be careful with these proposals. While well intentioned, they haveramifications that aren't instantly apparent. Each one needs some deepthought, user discussion, usability testing, and a darned good reasonfor changing what we already have in the field.Raymond
More information about the Python-Devmailing list
[8]ページ先頭