当引发未处理的异常时,您可以使用开关ipython
调用以将您转储到 python 调试器 (pdb) 中。--pdb
$ ipython --pdb
In [1]: 1/0
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-2-05c9758a9c21> in <module>()
----> 1 1/0
ZeroDivisionError: integer division or modulo by zero
> /usr/lib/python2.7/bdb.py(177)_set_stopinfo()
176 def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
--> 177 self.stopframe = stopframe
178 self.returnframe = returnframe
ipdb> whatis
*** SyntaxError: SyntaxError('unexpected EOF while parsing', ('<string>', 0, 0, ''))
ipdb> where
/usr/lib/python2.7/bdb.py(43)reset()
41 linecache.checkcache()
42 self.botframe = None
---> 43 self._set_stopinfo(None, None)
44
45 def trace_dispatch(self, frame, event, arg):
> /usr/lib/python2.7/bdb.py(177)_set_stopinfo()
175
176 def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
--> 177 self.stopframe = stopframe
178 self.returnframe = returnframe
179 self.quitting = 0
文档在pdb
这里:http ://docs.python.org/2/library/pdb.html