##// END OF EJS Templates
Prevent a nasty traceback if %debug is called before any exception has occurred.
Prevent a nasty traceback if %debug is called before any exception has occurred.

File last commit:

r439:2b7a1815
r491:306f7d93
Show More
ipy_pydb.py
31 lines | 814 B | text/x-python | PythonLexer
vivainio
R. Bernstein's patch for passing correct Pdb object to %pydb
r439 import inspect
vivainio
pydb_ipy.py extension adds %pydb magic when imported
r387 import IPython.ipapi
from IPython.genutils import arg_split
ip = IPython.ipapi.get()
vivainio
R. Bernstein's patch for passing correct Pdb object to %pydb
r439 from IPython import Debugger
vivainio
pydb_ipy.py extension adds %pydb magic when imported
r387 def call_pydb(self, args):
vivainio
R. Bernstein's patch for passing correct Pdb object to %pydb
r439 """Invoke pydb with the supplied parameters."""
try:
import pydb
except ImportError:
raise ImportError("pydb doesn't seem to be installed.")
if not hasattr(pydb.pydb, "runv"):
raise ImportError("You need pydb version 1.19 or later installed.")
vivainio
pydb_ipy.py extension adds %pydb magic when imported
r387 argl = arg_split(args)
vivainio
rm debug printing, fix typo bug
r388 # print argl # dbg
vivainio
R. Bernstein's patch for passing correct Pdb object to %pydb
r439 if len(inspect.getargspec(pydb.runv)[0]) == 2:
pdb = Debugger.Pdb()
ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )()
else:
ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )()
vivainio
pydb_ipy.py extension adds %pydb magic when imported
r387
ip.expose_magic("pydb",call_pydb)
vivainio
R. Bernstein's patch for passing correct Pdb object to %pydb
r439