Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert most changes
  • Loading branch information
iritkatriel committed Apr 7, 2023
commit 6e6f60bada5f2bba7c6c2e08b75eca19aef247aa
4 changes: 1 addition & 3 deletions Lib/idlelib/idle_test/test_stackviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def setUpClass(cls):
svs = stackviewer.sys
try:
abc
except NameError as exc:
svs.last_exc = exc
except NameError:
svs.last_type, svs.last_value, svs.last_traceback = (
sys.exc_info())

Expand All @@ -28,7 +27,6 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
svs = stackviewer.sys
del svs.last_exc
del svs.last_traceback, svs.last_type, svs.last_value

cls.root.update_idletasks()
Expand Down
7 changes: 2 additions & 5 deletions Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,14 +1367,11 @@ def open_stack_viewer(self, event=None):
if self.interp.rpcclt:
return self.interp.remote_stack_viewer()
try:
if hasattr(sys, 'last_exc'):
sys.last_exc.__traceback__
else:
sys.last_traceback
sys.last_traceback
except:
messagebox.showerror("No stack trace",
"There is no stack trace yet.\n"
"(sys.last_exc.__traceback__ or sys.last_traceback is not defined)",
"(sys.last_traceback is not defined)",
parent=self.text)
return
from idlelib.stackviewer import StackBrowser
Expand Down
21 changes: 6 additions & 15 deletions Lib/idlelib/stackviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def __init__(self, flist=None, tb=None):

def get_stack(self, tb):
if tb is None:
if hasattr(sys, 'last_exc'):
tb = sys.last_exc.__traceback__
else:
tb = sys.last_traceback
tb = sys.last_traceback
stack = []
if tb and tb.tb_frame is None:
tb = tb.tb_next
Expand All @@ -40,15 +37,11 @@ def get_stack(self, tb):
return stack

def get_exception(self):
if hasattr(sys, 'last_exc'):
typ = None if sys.last_exc is None else type(sys.last_exc)
value = sys.last_exc
else:
typ = sys.last_type
value = sys.last_value
if hasattr(typ, "__name__"):
typ = typ.__name__
s = str(typ)
type = sys.last_type
value = sys.last_value
if hasattr(type, "__name__"):
type = type.__name__
s = str(type)
if value is not None:
s = s + ": " + str(value)
return s
Expand Down Expand Up @@ -146,15 +139,13 @@ def _stack_viewer(parent): # htest #
sys.last_type = exc_type
sys.last_value = exc_value
sys.last_traceback = exc_tb
sys.last_exc = exc_value

StackBrowser(top, flist=flist, top=top, tb=exc_tb)

# restore sys to original state
del sys.last_type
del sys.last_value
del sys.last_traceback
del sys.last_exc

if __name__ == '__main__':
from unittest import main
Expand Down