'Create a crash handler, typically setting sys.excepthook to it.'

def init_crash_handler(self):

    self.crash_handler = self.crash_handler_class(self)
    sys.excepthook = self.excepthook
    def unset_crashhandler():
        sys.excepthook = sys.__excepthook__
    atexit.register(unset_crashhandler)
