[IPython-dev] Preventing "Oops, IPython crashed" ?

Hans Meine hans_meine at gmx.net
Fri Aug 5 05:35:43 CDT 2005


Hi again!

On Tuesday 31 May 2005 21:10, Fernando Perez wrote:
> Hans Meine wrote:
> > I forgot to ask this question, related to my Qt experiments: I loaded
> > some experimental GUI code, and noticed that exceptions resulting from
> > GUI actions result in this very verbose IPython traceback / bugreporting
> > output.
> >
> > Is there a way to get a similar traceback to the one I get when calling
> > functions manually from within IPython?
>
> Not that I know.  Unfortunately, exceptions raised in a different thread
> propagate all the way through to sys.excepthook, which is the ipython
> crash handler.  And I don't know of a way at that point of identifying
> whether the exception was caused by ipython code or by user code, so the
> crash handler just does its job and prints that monster traceback.
>
> This really annoys me a lot, but from all the googling and reading of
> maling lists which I did, it seemed to me that cross-thread exception
> handling in python was just somewhat limited.  I'd love to learn of a
> way around this problem, though, so by all means let me know if you are
> aware of a viable solution.

Indeed, that seems to be a serious problem.

> There is a workaround: you can manually reset sys.excepthook to the
> ipython  normal exception handler:
>
> sys.excepthook = __IPYTHON__.excepthook
>
> By running this line, you lose the real crash handler though, so if
> ipython proper crashes, I will get a LOT less debug information.  Caveat
> emptor.

I think this workaround should be documented somehow.  When working with GUI 
callbacks that possibly result in exceptions in a different thread, the long 
traceback is much less helpful than the shiny "normal" IPython one.  
(Congratulations on that BTW.)

Another workaround could be to color the long one, too (after all, it's mostly 
the missing color which bugs me), and either remove that from the report.txt 
or even send a colored report (although the usefulness depends on your mailer 
since it's not attached but in the mail body) which you can dump to a 
console?

Ciao, /  /
     /--/
    /  / ANS




More information about the IPython-dev mailing list