Opening an IPython shell on any (uncaught) exception

后端 未结 2 1941
猫巷女王i
猫巷女王i 2021-01-15 13:44

I have defined the following (embedded) shell in Python:

from IPython.config.loader import Config
cfg = Config()
prompt_config = cfg.PromptManager
prompt_con         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 14:12

    Defining the following in my ipython shell seems to do what you want:

    def custom_exc(shell, etype, evalue, tb, tb_offset=None):
        shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset)
        ipshell()
    
    get_ipython().set_custom_exc((Exception,), custom_exc)
    

提交回复
热议问题