From 78d44483560a57883191462fe6b4337ee8e79f43 2012-11-02 23:12:05 From: Bradley M. Froehle Date: 2012-11-02 23:12:05 Subject: [PATCH] Maintain backwards compatibility in BdbQuit_excepthook.excepthook_ori. --- diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 85cd2ce..cf81b78 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -27,6 +27,7 @@ http://www.python.org/2.2.3/license.html""" from __future__ import print_function import bdb +import functools import linecache import sys @@ -59,11 +60,19 @@ else: # Allow the set_trace code to operate outside of an ipython instance, even if # it does so with some limitations. The rest of this support is implemented in # the Tracer constructor. -def BdbQuit_excepthook(et,ev,tb,orig_hook): +def BdbQuit_excepthook(et, ev, tb, excepthook=None): + """Exception hook which handles `BdbQuit` exceptions. + + All other exceptions are processed using the `excepthook` + parameter. + """ if et==bdb.BdbQuit: print('Exiting Debugger.') + elif excepthook is not None: + excepthook(et, ev, tb) else: - orig_hook(et,ev,tb) + # Backwards compatibility. Raise deprecation warning? + BdbQuit_excepthook.excepthook_ori(et,ev,tb) def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): print('Exiting Debugger.') @@ -108,8 +117,8 @@ class Tracer(object): ip = get_ipython() except NameError: # Outside of ipython, we set our own exception hook manually - sys.excepthook = lambda et, ev, tb, orig_hook=sys.excepthook: \ - BdbQuit_excepthook(et, ev, tb, orig_hook) + sys.excepthook = functools.partial(BdbQuit_excepthook, + excepthook=sys.excepthook) def_colors = 'NoColor' try: # Limited tab completion support