[IPython-dev] Ctrl-C quitting ipython

Hans Meine hans_meine@gmx....
Thu Nov 4 08:37:33 CDT 2010

Op den Dunnersdag 04 November 2010 Klock 07:19:41 hett Fernando Perez 
> > - whether that would be annoying (don't know how noisy the result would
> > be) - whether we can catch exit() being called and at least report
> > "IPython noticed some extension/C-code called exit()", which would have
> > at least reduced the debugging time for us
> Nope, unfortunately there's no way to catch that, to the best of my
> knowledge (would love to be proven wrong, though).

There would be a way with C code, but that's against ipython's design AFAICS:
One could write a tiny extension that uses atexit(3) to register a handler 
which prints a warning after checking a flag whether the exit was expected 
(initiated from IPython).

To a certain degree, it is possible to do the same with ctypes, but AFAICS the 
case in which python was shut down would make problems (since the handler 
would be implemented in python code, but the interpreter will already be shut 

At least, sys.exit() / SystemExit is already caught.  However, I find it 
strange that %tb is announced, while it does not give a valuable result:

In [6]: sys.exit()
An exception has occurred, use %tb to see the full traceback.


To exit: use any of 'exit', 'quit', %Exit or Ctrl-D.

In [7]: %tb
IndexError                                Traceback (most recent call last)
IndexError: list index out of range

Have a nice day,

More information about the IPython-dev mailing list