[IPython-dev] Nicer display of exceptions with ipython1

Gael Varoquaux gael.varoquaux at normalesup.org
Sun Jul 20 16:54:29 EDT 2008

Currently, with the ipython1 interpreter, there are two ways of dealing
with exception: either you let the interpreter deal with them, and you
get the traceback in the return message, or you ask the interpreter to
raise them, and you deal with them yourself.

I have been doing the second, in my frontend, because I want my frontend
to be able to display more information about the traceback that there is
in the message. The problem with this is that I have to catch the
exception outside of the interpreter, thus the callstack contains
irrelevant information, for instance this is the kind of session I might

In [1]: print i
NameError                                 Traceback (most recent call

in execute_block(self, code)
    373         outflag = 1 # start by assuming error, success will reset
    374         try:
--> 375             exec code in self.user_ns
    376             outflag = 00    377
except         SystemExit

<module>() in 
----> 1 

It seems to me that an elegant way to resolve this problem would be to
provide a callback to the interpreter to deal with traceback. I am
looking at the traceback_trap and trying to figure out if what I want
fits in this model or not, and I am not too sure it does. I think I want
something more flexible.

Should I go ahead and implement a callback somewhere? And if so, where?
In the traceback trap?



More information about the IPython-dev mailing list