Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #28 from marciomazza/master

Check to wrap sys.excepthook only once
  • Loading branch information...
commit 50c7ede8b2c9f9b6626aca84202d3c3eac220e22 2 parents 21c0989 + dd70a77
@gotcha authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 ipdb/__main__.py
View
12 ipdb/__main__.py
@@ -58,11 +58,16 @@ def update_stdout():
# setup stdout to ensure output is available with nose
Term.cout = sys.stdout = sys.__stdout__
+def wrap_sys_excepthook():
+ # make sure we wrap it only once or we would end up with a cycle
+ # BdbQuit_excepthook.excepthook_ori == BdbQuit_excepthook
+ if sys.excepthook != BdbQuit_excepthook:
+ BdbQuit_excepthook.excepthook_ori = sys.excepthook
+ sys.excepthook = BdbQuit_excepthook
def set_trace(frame=None):
update_stdout()
- BdbQuit_excepthook.excepthook_ori = sys.excepthook
- sys.excepthook = BdbQuit_excepthook
+ wrap_sys_excepthook()
if frame is None:
frame = sys._getframe().f_back
Pdb(def_colors).set_trace(frame)
@@ -70,8 +75,7 @@ def set_trace(frame=None):
def post_mortem(tb):
update_stdout()
- BdbQuit_excepthook.excepthook_ori = sys.excepthook
- sys.excepthook = BdbQuit_excepthook
+ wrap_sys_excepthook()
p = Pdb(def_colors)
p.reset()
if tb is None:
Please sign in to comment.
Something went wrong with that request. Please try again.