From c57da7457b26203c59afbbbc499ec77ea71181fa Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Mon, 3 Mar 2014 20:42:11 -0800 Subject: [PATCH] fix pdb_on_signal, add a helpful comment --- boltons/debugutils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/boltons/debugutils.py b/boltons/debugutils.py index 5ac4f0f..27d9d80 100644 --- a/boltons/debugutils.py +++ b/boltons/debugutils.py @@ -1,14 +1,18 @@ # -*- coding: utf-8 -*- -def pdb_on_signal(signal=None): +def pdb_on_signal(signalnum=None): import pdb import signal - if not signal: - signal = signal.SIGINT + if not signalnum: + signalnum = signal.SIGINT + + old_handler = signal.getsignal(signalnum) def pdb_int_handler(sig, frame): + signal.signal(signalnum, old_handler) pdb.set_trace() + pdb_on_signal(signalnum) # use 'u' to find your code and 'h' for help - signal.signal(signal.SIGINT, pdb_int_handler) + signal.signal(signalnum, pdb_int_handler) return