views:

195

answers:

2

I try to customize behavior of sys.excepthook as described by the recipe.

in ipython:

:import pdb, sys, traceback
:def info(type, value, tb):
:    traceback.print_exception(type, value, tb)
:    pdb.pm()
:sys.excepthook = info
:--
>>> x[10] = 5
-------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
NameError: name 'x' is not defined
>>>

pdb.pm() is not being called. It seems that sys.excepthook = info doesn't work in my python 2.5 installation.

What should I look into? Any suggestion?

Thank you

A: 

See this SO question and make sure there isn't something in your sitecustomize.py that prevents debugging in interactive mode.

scrible
+3  A: 

ipython, which you're using instead of the normal Python interactive shell, traps all exceptions itself and does NOT use sys.excepthook. Run it as ipython -pdb instead of just ipython, and it will automatically invoke pdb upon uncaught exceptions, just as you are trying to do with your excepthook.

Alex Martelli