[IPython-dev] excepthook-like behavior in ipython

Erik Tollerud erik.tollerud at gmail.com
Mon Apr 9 21:39:38 EDT 2012

Hello all,

I noticed some odd (although I now realize quite sensible) behavior in
IPython, and I'm curious if there's a workaround.  I have an
application log that I want to use to capture unhandled exceptions.
When not using IPython, it's straightforward to just override
sys.excepthook to first sent the exception to our logging system, and
then continue the normal excepthook behavior.  However, IPython seems
to always use only its own excepthook in interactive mode
(TerminalInteractiveShell.excepthook, at least in the standard

So my question is: Is there any way to plug anything into the IPython
exception handling system, either with sys.excepthook-style syntax, or
some other way?  As I said, it doesn't have to actually catch the
exceptions - we just want entries placed in a log if an interactive
session hits an unhandled exception, and it could then pass normally
into the IPython formatting/pdb running system.

Erik Tollerud

More information about the IPython-dev mailing list