Movatterモバイル変換
[0]ホーム
[Python-Dev] Exception masking/chaining
Greg Ewinggreg@cosc.canterbury.ac.nz
Fri, 13 Jun 2003 12:31:12 +1200 (NZST)
Guido:> There's a lot of C code out there that catches e.g. AttributeError and> replaces it with a more specific error (e.g. BifurcationError("can't> bifurcate the sploorg") replacing AttributeError("__bifurcate__"). I> think this would cause end user confusion.But that is a different case. As I understand it, chaining would onlyoccur if a second exception was raised *before* the current exceptionwas caught -- e.g. if there's a bug in a piece of code in a finallyblock that's being executed while unwinding to find an exceptionhandler.In the case you're talking about, the AttributeError has been caughtby the time the BifurcationError is raised, so there would be nochaining, and thus the traceback output would be the same regardlessof whether chained tracebacks were printed or not.As for whether chained tracebacks should be printed when they occur,I'll have to think about that. If they are, probably the one for themost recently raised exception should be printed last, since one tendsto look at the bottom of the traceback first to find the cause of theimmediate problem (I do, at least).Greg Ewing, Computer Science Dept, +--------------------------------------+University of Canterbury, | A citizen of NewZealandCorp, a |Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |greg@cosc.canterbury.ac.nz +--------------------------------------+
[8]ページ先頭