mirror of
https://github.com/python/cpython.git
synced 2025-10-04 22:20:46 +00:00
bpo-43008: Make IDLE respect sys.excepthook (GH-24302)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 7a34380ad7
)
Co-authored-by: Ken <kenny2minecraft@gmail.com>
This commit is contained in:
parent
fd668bc62b
commit
68102fb998
5 changed files with 65 additions and 15 deletions
|
@ -16,6 +16,7 @@ import _thread as thread
|
|||
import threading
|
||||
import warnings
|
||||
|
||||
import idlelib # testing
|
||||
from idlelib import autocomplete # AutoComplete, fetch_encodings
|
||||
from idlelib import calltip # Calltip
|
||||
from idlelib import debugger_r # start_debugger
|
||||
|
@ -542,14 +543,17 @@ class Executive:
|
|||
|
||||
def __init__(self, rpchandler):
|
||||
self.rpchandler = rpchandler
|
||||
self.locals = __main__.__dict__
|
||||
self.calltip = calltip.Calltip()
|
||||
self.autocomplete = autocomplete.AutoComplete()
|
||||
if idlelib.testing is False:
|
||||
self.locals = __main__.__dict__
|
||||
self.calltip = calltip.Calltip()
|
||||
self.autocomplete = autocomplete.AutoComplete()
|
||||
else:
|
||||
self.locals = {}
|
||||
|
||||
def runcode(self, code):
|
||||
global interruptable
|
||||
try:
|
||||
self.usr_exc_info = None
|
||||
self.user_exc_info = None
|
||||
interruptable = True
|
||||
try:
|
||||
exec(code, self.locals)
|
||||
|
@ -562,10 +566,17 @@ class Executive:
|
|||
print('SystemExit: ' + str(ob), file=sys.stderr)
|
||||
# Return to the interactive prompt.
|
||||
except:
|
||||
self.usr_exc_info = sys.exc_info()
|
||||
self.user_exc_info = sys.exc_info() # For testing, hook, viewer.
|
||||
if quitting:
|
||||
exit()
|
||||
print_exception()
|
||||
if sys.excepthook is sys.__excepthook__:
|
||||
print_exception()
|
||||
else:
|
||||
try:
|
||||
sys.excepthook(*self.user_exc_info)
|
||||
except:
|
||||
self.user_exc_info = sys.exc_info() # For testing.
|
||||
print_exception()
|
||||
jit = self.rpchandler.console.getvar("<<toggle-jit-stack-viewer>>")
|
||||
if jit:
|
||||
self.rpchandler.interp.open_remote_stack_viewer()
|
||||
|
@ -590,8 +601,8 @@ class Executive:
|
|||
return self.autocomplete.fetch_completions(what, mode)
|
||||
|
||||
def stackviewer(self, flist_oid=None):
|
||||
if self.usr_exc_info:
|
||||
typ, val, tb = self.usr_exc_info
|
||||
if self.user_exc_info:
|
||||
typ, val, tb = self.user_exc_info
|
||||
else:
|
||||
return None
|
||||
flist = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue