# -*- coding: utf-8 -*-


def pdb_on_signal(signal=None):
    import pdb
    import signal
    if not signal:
        signal = signal.SIGINT

    def pdb_int_handler(sig, frame):
        pdb.set_trace()

    signal.signal(signal.SIGINT, pdb_int_handler)
    return

# -*- coding: utf-8 -*-


def pdb_on_signal(signalnum=None):
    import pdb
    import signal
    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(signalnum, pdb_int_handler)
    return

fix pdb_on_signal, add a helpful comment