Skip to content

Commit 4d1f033

Browse files
authored
gh-102778: revert changes to idlelib (#102825)
1 parent ccb5af7 commit 4d1f033

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

Lib/idlelib/idle_test/test_stackviewer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def setUpClass(cls):
1919
except NameError:
2020
svs.last_type, svs.last_value, svs.last_traceback = (
2121
sys.exc_info())
22-
svs.last_exc = svs.last_value
2322

2423
requires('gui')
2524
cls.root = Tk()
@@ -28,7 +27,7 @@ def setUpClass(cls):
2827
@classmethod
2928
def tearDownClass(cls):
3029
svs = stackviewer.sys
31-
del svs.last_exc, svs.last_traceback, svs.last_type, svs.last_value
30+
del svs.last_traceback, svs.last_type, svs.last_value
3231

3332
cls.root.update_idletasks()
3433
## for id in cls.root.tk.call('after', 'info'):

Lib/idlelib/pyshell.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1367,14 +1367,11 @@ def open_stack_viewer(self, event=None):
13671367
if self.interp.rpcclt:
13681368
return self.interp.remote_stack_viewer()
13691369
try:
1370-
if hasattr(sys, 'last_exc'):
1371-
sys.last_exc.__traceback__
1372-
else:
1373-
sys.last_traceback
1370+
sys.last_traceback
13741371
except:
13751372
messagebox.showerror("No stack trace",
13761373
"There is no stack trace yet.\n"
1377-
"(sys.last_exc and sys.last_traceback are not defined)",
1374+
"(sys.last_traceback is not defined)",
13781375
parent=self.text)
13791376
return
13801377
from idlelib.stackviewer import StackBrowser

Lib/idlelib/run.py

-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ def print_exception():
239239
efile = sys.stderr
240240
typ, val, tb = excinfo = sys.exc_info()
241241
sys.last_type, sys.last_value, sys.last_traceback = excinfo
242-
sys.last_exc = val
243242
seen = set()
244243

245244
def print_exc(typ, exc, tb):
@@ -630,7 +629,6 @@ def stackviewer(self, flist_oid=None):
630629
flist = self.rpchandler.get_remote_proxy(flist_oid)
631630
while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
632631
tb = tb.tb_next
633-
sys.last_exc = val
634632
sys.last_type = typ
635633
sys.last_value = val
636634
item = stackviewer.StackTreeItem(flist, tb)

Lib/idlelib/stackviewer.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ def __init__(self, flist=None, tb=None):
2727

2828
def get_stack(self, tb):
2929
if tb is None:
30-
if hasattr(sys, 'last_exc'):
31-
tb = sys.last_exc.__traceback__
32-
else:
33-
tb = sys.last_traceback
30+
tb = sys.last_traceback
3431
stack = []
3532
if tb and tb.tb_frame is None:
3633
tb = tb.tb_next
@@ -40,15 +37,11 @@ def get_stack(self, tb):
4037
return stack
4138

4239
def get_exception(self):
43-
if hasattr(sys, 'last_exc'):
44-
typ = type(sys.last_exc)
45-
value = sys.last_exc
46-
else:
47-
typ = sys.last_type
48-
value = sys.last_value
49-
if hasattr(typ, "__name__"):
50-
typ = typ.__name__
51-
s = str(typ)
40+
type = sys.last_type
41+
value = sys.last_value
42+
if hasattr(type, "__name__"):
43+
type = type.__name__
44+
s = str(type)
5245
if value is not None:
5346
s = s + ": " + str(value)
5447
return s
@@ -143,15 +136,13 @@ def _stack_viewer(parent): # htest #
143136
except NameError:
144137
exc_type, exc_value, exc_tb = sys.exc_info()
145138
# inject stack trace to sys
146-
sys.last_exc = exc_value
147139
sys.last_type = exc_type
148140
sys.last_value = exc_value
149141
sys.last_traceback = exc_tb
150142

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

153145
# restore sys to original state
154-
del sys.last_exc
155146
del sys.last_type
156147
del sys.last_value
157148
del sys.last_traceback

0 commit comments

Comments
 (0)