Movatterモバイル変換
[0]ホーム
[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0
Stephen J. Turnbullstephen at xemacs.org
Tue Aug 2 05:25:48 CEST 2005
>>>>> "Willem" == Willem Broekema <metawilm at gmail.com> writes: Willem> So, in short, Keyboard interrupts in Lisp are a Willem> serious-condition, not an error. Willem> (And what is labeled CriticalException in this discussion, Willem> has in serious-condition Lisp's counterpart.)I don't see it that way. Rather, "Raisable" is the closest equivalentto "serious-condition", and "CriticalException" is an intermediateclass that has no counterpart in Lisp usage. >> and if an unhandled signal whose intended interpretation is >> "drop the gun and put your hands on your head!" isn't critical, >> what is?<wink> Willem> Eh, are you serious? <wink>Yes. Unhandled, KeyboardInterrupt means that the user has forciblytaken control away from the program without giving it a chance topreserve state, finish responding to (realtime) external conditions,or even activate vacation(1), and the program is entirely at the mercyof the user. Usually, the program then proceeds to die withoutdignity. If it's a realtime application, killing it is probably theonly merciful thing to do.If you were the program, wouldn't you consider that critical? Willem> But when CriticalException, despite its name, is not a Willem> subclass of Exception, that is a bit strange.Granted. It doesn't bother me, but since it bothers both you andPhilip Eby, I concede the point; we should find a better name (or notbother with such a class, see below). Willem> I'd prefer the 'condition' and 'error' terminology, and to Willem> label a keyboard interrupt a condition, not any kind of Willem> exception or error.Now, that does bother me.<wink> Anything we will not permit a programto ignore with a bare "except: pass" if it so chooses had better bemore serious than merely a "condition". Also, to me a "condition" issomething that I poll for, it does not interrupt me. To me, acondition (even a serious one) is precisely the kind of thing that Ishould be able to ignore with a bare except!Your description of the CL hierarchy makes me wonder if there's anybenefit to having a class between Raisable and KeyboardInterrupt.Unlike SystemShutdown or PowerFailure, KeyboardInterrupt does implypresence of a user demanding attention; I suppose that warrantsspecial treatment. On the other hand, I don't see a need for a classwhose members share only the property that they are not catchable witha bare except, leading toRaisable -+- Exception +- KeyboardInterrupt +- SystemShutdown +- PowerFailure +- (etc)or evenException -+- CatchableException +- KeyboardInterrupt +- SystemShutdown +- PowerFailure +- (etc)The latter is my mental model, and would work well with bare excepts.It also would encourage the programmer to think about whetheran Exception should be catchable or is a special case, but I don'tthink that's really helpful except for Python developers, whopresumably would be aware of the issues.The former would be a compromise to allow "except Exception" to be anatural idiom, which I prefer to bare excepts on stylistic grounds.On balance, that's what I advocate.-- School of Systems and Information Engineeringhttp://turnbull.sk.tsukuba.ac.jpUniversity of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.
More information about the Python-Devmailing list
[8]ページ先頭