From 942ff16673c623ce2b9a86e84fab31cb99b62b65 Mon Sep 17 00:00:00 2001 From: Ken Date: Sat, 23 Jan 2021 19:23:25 +0800 Subject: [PATCH] Make IDLE respect sys.excepthook --- Lib/idlelib/run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 1e84ecc6584ef..1d0cf5c8a178b 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -565,7 +565,10 @@ def runcode(self, code): self.usr_exc_info = sys.exc_info() if quitting: exit() - print_exception() + if sys.excepthook is sys.__excepthook__: + print_exception() + else: + sys.excepthook(*self.usr_exc_info) jit = self.rpchandler.console.getvar("<>") if jit: self.rpchandler.interp.open_remote_stack_viewer()