From: Fernando P. <Fer...@co...> - 2004-11-22 22:43:21
|
John Hunter schrieb: >>>>>>"Steve" == Steve Chaplin <ste...@ya...> writes: > > > Steve> By subclassing Verbose you group all the functions that > Steve> display messages to the user together into one class. I > Steve> may have misunderstood some of the discussion - I agree > Steve> with doing all error handling with exceptions, but when you > Steve> catch the exception in a GUI I'm assuming you still want to > Steve> popup a message to inform the user. Are you describing > Steve> using exceptions and tracebacks without any error messages > Steve> for GUI backends? I don't think you can assume a GUI > Steve> backend user will see a traceback since the terminal window > Steve> may be obscured, iconified or even closed. > > For the GUI error handling, I was assuming we would use the > except_hook, and do away with error reporting in the verbose class. I'd like to strongly plead that you stay away from sys.excepthook. That is the 'last resort' tool to manipulate exceptions, and it's typically used by frameworks which need to completely control the python process. For example, ipython puts its internal crash handler in sys.excepthook, so that if all else fails, the crash handler generates a very detailed crash report. But all 'normal' exception handling is done by the internal user loop, with manual control. I haven't had time to look in detail, but I even think that ipython pretty aggressively reclaims sys.excepthook if user code messes with it. I wouldn't be surprised if other frameworks (like envisage) also used sys.excepthook themselves. Matplotlib is 'only' a plotting library :), and it should IMHO play nicely with other code running along with it. If it gets into a foodfight over who owns sys.excepthook, or if it crashes because sys.excepthook is not what it thinks it is, I expect serious interoperability problems to pop up down the road. I realize that excepthook is a tempting tool to use, but I hope you guys reconsider this. I really think it would cause many more headaches down the road than those it initially appears to solve. Regards, f |