From: Fernando P. <Fer...@co...> - 2004-11-22 23:08:45
|
John Hunter schrieb: >>>>>>"Fernando" == Fernando Perez <Fer...@co...> writes: > > > >> Actually, it would be fine if matplotlib overrode > >> sys.except_hook and ipython later came along and overrode that. > >> Basically, ipython would be saying, "I know I've got a shell to > >> display errors in, so we don't need to GUI method". I don't > >> think matplotlib would have a problem with that. Ditto for > >> envisage. Basically, we would be providing a default method to > >> get the message to the GUI which could be overriden by other > >> applications that want to (ipython, envisage, what-have-you). > > Fernando> I guess this is a good heads-up for me. I know ipython > Fernando> does some of this, I'll just add a bit more such > Fernando> control. That way, if during the running of user code > Fernando> they need sys.ehook for something, they'll get it. But > Fernando> ipython will keep it for when it needs it. I'm pretty > Fernando> sure the embeddable ipython has such control in it, I > Fernando> may just need to put it in the general case as well. > > Fernando> Ultimately I'm not 100% sure what a good solution for > Fernando> matplotlib is, I just wanted to make you aware of these > Fernando> issues, so that at least they are on your radar. > > > We do have some more options. For one, we could use the excepthook > only in the matlab interface -- in this case matlab is being used more > as an application rather than a library. Folks using matplotlib as a > library, eg embedding in a GUI, would be advised to do their own > trapping. > > The only exceptional case I see is basically the ipython (and friends) > case. Ie, someone wants to write a shell or otherwise that embeds > matplotlib.matlab. In this case it would be fine to override > matplotlib.matlab's excepthook, as discussed. > > To play really nicely, matplotlib.matlab would like to be able to > override excepthook only if it hadn't been otherwise overridden. I > don't see any elegant way to do this. Any ideas? Yup: planck[mayavi]> ip In [1]: import sys In [2]: sys.__excepthook__ is sys.excepthook Out[2]: False planck[mayavi]> python >>> import sys >>> sys.__excepthook__ is sys.excepthook True Cheers, f |