Show More
@@ -27,6 +27,7 b' http://www.python.org/2.2.3/license.html"""' | |||||
27 | from __future__ import print_function |
|
27 | from __future__ import print_function | |
28 |
|
28 | |||
29 | import bdb |
|
29 | import bdb | |
|
30 | import functools | |||
30 | import linecache |
|
31 | import linecache | |
31 | import sys |
|
32 | import sys | |
32 |
|
33 | |||
@@ -59,11 +60,19 b' else:' | |||||
59 | # Allow the set_trace code to operate outside of an ipython instance, even if |
|
60 | # Allow the set_trace code to operate outside of an ipython instance, even if | |
60 | # it does so with some limitations. The rest of this support is implemented in |
|
61 | # it does so with some limitations. The rest of this support is implemented in | |
61 | # the Tracer constructor. |
|
62 | # the Tracer constructor. | |
62 |
def BdbQuit_excepthook(et,ev,tb, |
|
63 | def BdbQuit_excepthook(et, ev, tb, excepthook=None): | |
|
64 | """Exception hook which handles `BdbQuit` exceptions. | |||
|
65 | ||||
|
66 | All other exceptions are processed using the `excepthook` | |||
|
67 | parameter. | |||
|
68 | """ | |||
63 | if et==bdb.BdbQuit: |
|
69 | if et==bdb.BdbQuit: | |
64 | print('Exiting Debugger.') |
|
70 | print('Exiting Debugger.') | |
|
71 | elif excepthook is not None: | |||
|
72 | excepthook(et, ev, tb) | |||
65 | else: |
|
73 | else: | |
66 | orig_hook(et,ev,tb) |
|
74 | # Backwards compatibility. Raise deprecation warning? | |
|
75 | BdbQuit_excepthook.excepthook_ori(et,ev,tb) | |||
67 |
|
76 | |||
68 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): |
|
77 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): | |
69 | print('Exiting Debugger.') |
|
78 | print('Exiting Debugger.') | |
@@ -108,8 +117,8 b' class Tracer(object):' | |||||
108 | ip = get_ipython() |
|
117 | ip = get_ipython() | |
109 | except NameError: |
|
118 | except NameError: | |
110 | # Outside of ipython, we set our own exception hook manually |
|
119 | # Outside of ipython, we set our own exception hook manually | |
111 |
sys.excepthook = |
|
120 | sys.excepthook = functools.partial(BdbQuit_excepthook, | |
112 | BdbQuit_excepthook(et, ev, tb, orig_hook) |
|
121 | excepthook=sys.excepthook) | |
113 | def_colors = 'NoColor' |
|
122 | def_colors = 'NoColor' | |
114 | try: |
|
123 | try: | |
115 | # Limited tab completion support |
|
124 | # Limited tab completion support |
General Comments 0
You need to be logged in to leave comments.
Login now