[IPython-dev] Clearing exception info stored for %debug?

Fernando Perez fperez.net at gmail.com
Tue Jun 3 21:03:46 EDT 2008

Hi Hans,

2008/1/18 Hans Meine <hans_meine at gmx.net>:
> Hi!
> I just suffered from a complicated situation; I had a file being clobbered on
> IPython quit by a __del__ method from one of the objects in the stack within
> an exception that occurred earlier.  After the exception, I only ran one
> corrected command which stored the right file after a long computation, but
> when I quit IPython the data was overwritten by the partial results from the
> earlier, broken run.
> This situation is probably a rare one, but I thought that one might want to
> introduce "%clear exception" or sth. along that lines.

Could you be more specific on how such clearing would be implemented?
As far as I know, Python doesn't provide an official API for exception
clearing, but I could well be wrong.  sys holds certain special

In [2]: sys.last
sys.last_traceback  sys.last_type       sys.last_value

that only appear after an exception has occurred.  One could
concievably delete those straight from the sys module dict, but that
feels a bit harsh.  And in addition, references could be held
elsewhere, there's no easy way in python for finding all references
held to an object (or is there?).  So I'm not opposed in principle to
your idea, I'm just not quite sure how to go about it...



More information about the IPython-dev mailing list