mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-102778: revert changes to idlelib (#102825)
This commit is contained in:
parent
ccb5af7bfe
commit
4d1f033986
4 changed files with 9 additions and 24 deletions
|
@ -19,7 +19,6 @@ class StackBrowserTest(unittest.TestCase):
|
||||||
except NameError:
|
except NameError:
|
||||||
svs.last_type, svs.last_value, svs.last_traceback = (
|
svs.last_type, svs.last_value, svs.last_traceback = (
|
||||||
sys.exc_info())
|
sys.exc_info())
|
||||||
svs.last_exc = svs.last_value
|
|
||||||
|
|
||||||
requires('gui')
|
requires('gui')
|
||||||
cls.root = Tk()
|
cls.root = Tk()
|
||||||
|
@ -28,7 +27,7 @@ class StackBrowserTest(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
svs = stackviewer.sys
|
svs = stackviewer.sys
|
||||||
del svs.last_exc, svs.last_traceback, svs.last_type, svs.last_value
|
del svs.last_traceback, svs.last_type, svs.last_value
|
||||||
|
|
||||||
cls.root.update_idletasks()
|
cls.root.update_idletasks()
|
||||||
## for id in cls.root.tk.call('after', 'info'):
|
## for id in cls.root.tk.call('after', 'info'):
|
||||||
|
|
|
@ -1367,14 +1367,11 @@ class PyShell(OutputWindow):
|
||||||
if self.interp.rpcclt:
|
if self.interp.rpcclt:
|
||||||
return self.interp.remote_stack_viewer()
|
return self.interp.remote_stack_viewer()
|
||||||
try:
|
try:
|
||||||
if hasattr(sys, 'last_exc'):
|
sys.last_traceback
|
||||||
sys.last_exc.__traceback__
|
|
||||||
else:
|
|
||||||
sys.last_traceback
|
|
||||||
except:
|
except:
|
||||||
messagebox.showerror("No stack trace",
|
messagebox.showerror("No stack trace",
|
||||||
"There is no stack trace yet.\n"
|
"There is no stack trace yet.\n"
|
||||||
"(sys.last_exc and sys.last_traceback are not defined)",
|
"(sys.last_traceback is not defined)",
|
||||||
parent=self.text)
|
parent=self.text)
|
||||||
return
|
return
|
||||||
from idlelib.stackviewer import StackBrowser
|
from idlelib.stackviewer import StackBrowser
|
||||||
|
|
|
@ -239,7 +239,6 @@ def print_exception():
|
||||||
efile = sys.stderr
|
efile = sys.stderr
|
||||||
typ, val, tb = excinfo = sys.exc_info()
|
typ, val, tb = excinfo = sys.exc_info()
|
||||||
sys.last_type, sys.last_value, sys.last_traceback = excinfo
|
sys.last_type, sys.last_value, sys.last_traceback = excinfo
|
||||||
sys.last_exc = val
|
|
||||||
seen = set()
|
seen = set()
|
||||||
|
|
||||||
def print_exc(typ, exc, tb):
|
def print_exc(typ, exc, tb):
|
||||||
|
@ -630,7 +629,6 @@ class Executive:
|
||||||
flist = self.rpchandler.get_remote_proxy(flist_oid)
|
flist = self.rpchandler.get_remote_proxy(flist_oid)
|
||||||
while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
|
while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
sys.last_exc = val
|
|
||||||
sys.last_type = typ
|
sys.last_type = typ
|
||||||
sys.last_value = val
|
sys.last_value = val
|
||||||
item = stackviewer.StackTreeItem(flist, tb)
|
item = stackviewer.StackTreeItem(flist, tb)
|
||||||
|
|
|
@ -27,10 +27,7 @@ class StackTreeItem(TreeItem):
|
||||||
|
|
||||||
def get_stack(self, tb):
|
def get_stack(self, tb):
|
||||||
if tb is None:
|
if tb is None:
|
||||||
if hasattr(sys, 'last_exc'):
|
tb = sys.last_traceback
|
||||||
tb = sys.last_exc.__traceback__
|
|
||||||
else:
|
|
||||||
tb = sys.last_traceback
|
|
||||||
stack = []
|
stack = []
|
||||||
if tb and tb.tb_frame is None:
|
if tb and tb.tb_frame is None:
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
|
@ -40,15 +37,11 @@ class StackTreeItem(TreeItem):
|
||||||
return stack
|
return stack
|
||||||
|
|
||||||
def get_exception(self):
|
def get_exception(self):
|
||||||
if hasattr(sys, 'last_exc'):
|
type = sys.last_type
|
||||||
typ = type(sys.last_exc)
|
value = sys.last_value
|
||||||
value = sys.last_exc
|
if hasattr(type, "__name__"):
|
||||||
else:
|
type = type.__name__
|
||||||
typ = sys.last_type
|
s = str(type)
|
||||||
value = sys.last_value
|
|
||||||
if hasattr(typ, "__name__"):
|
|
||||||
typ = typ.__name__
|
|
||||||
s = str(typ)
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
s = s + ": " + str(value)
|
s = s + ": " + str(value)
|
||||||
return s
|
return s
|
||||||
|
@ -143,7 +136,6 @@ def _stack_viewer(parent): # htest #
|
||||||
except NameError:
|
except NameError:
|
||||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||||
# inject stack trace to sys
|
# inject stack trace to sys
|
||||||
sys.last_exc = exc_value
|
|
||||||
sys.last_type = exc_type
|
sys.last_type = exc_type
|
||||||
sys.last_value = exc_value
|
sys.last_value = exc_value
|
||||||
sys.last_traceback = exc_tb
|
sys.last_traceback = exc_tb
|
||||||
|
@ -151,7 +143,6 @@ def _stack_viewer(parent): # htest #
|
||||||
StackBrowser(top, flist=flist, top=top, tb=exc_tb)
|
StackBrowser(top, flist=flist, top=top, tb=exc_tb)
|
||||||
|
|
||||||
# restore sys to original state
|
# restore sys to original state
|
||||||
del sys.last_exc
|
|
||||||
del sys.last_type
|
del sys.last_type
|
||||||
del sys.last_value
|
del sys.last_value
|
||||||
del sys.last_traceback
|
del sys.last_traceback
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue