code: def install_hook(dialog=SimpleExceptionDialog, invoke_old_hook=False, **extra):
      
      global _old_hook
      assert _old_hook is None
  
      def new_hook(etype, eval, trace):
          gobject.idle_add(dialog_handler, dialog, etype, eval, trace, extra)
          if invoke_old_hook:
              _old_hook(etype, eval, trace)
  
      _old_hook = sys.excepthook
      sys.excepthook = new_hook
docs: install the configured exception hook wrapping the old exception hook
  
      don't use it twice
  
      :oparam dialog: a different exception dialog class
      :oparam invoke_old_hook: should we invoke the old exception hook?