]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-102778: revert changes to idlelib (#102825)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Sun, 19 Mar 2023 16:19:59 +0000 (16:19 +0000)
committerGitHub <noreply@github.com>
Sun, 19 Mar 2023 16:19:59 +0000 (12:19 -0400)
Lib/idlelib/idle_test/test_stackviewer.py
Lib/idlelib/pyshell.py
Lib/idlelib/run.py
Lib/idlelib/stackviewer.py

index f4626bb1702a307eea9003d96a2ca8e8d0280415..98f53f9537bb25727b8d61da5343d0ecd1d7f65d 100644 (file)
@@ -19,7 +19,6 @@ class StackBrowserTest(unittest.TestCase):
         except NameError:
             svs.last_type, svs.last_value, svs.last_traceback = (
                 sys.exc_info())
-            svs.last_exc = svs.last_value
 
         requires('gui')
         cls.root = Tk()
@@ -28,7 +27,7 @@ class StackBrowserTest(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         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()
 ##        for id in cls.root.tk.call('after', 'info'):
index edc77ff26f62f7894bdb5ffc2f9e36fd77676f10..e68233a5a4131e42fa8ace277704147c7fea73d2 100755 (executable)
@@ -1367,14 +1367,11 @@ class PyShell(OutputWindow):
         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 and sys.last_traceback are not defined)",
+                "(sys.last_traceback is not defined)",
                 parent=self.text)
             return
         from idlelib.stackviewer import StackBrowser
index 6a7b50cf5cfb27001b2c863ad122a70429d5c58b..577c49eb67b20d1f83095b3224d341cd88ad1656 100644 (file)
@@ -239,7 +239,6 @@ def print_exception():
     efile = sys.stderr
     typ, val, tb = excinfo = sys.exc_info()
     sys.last_type, sys.last_value, sys.last_traceback = excinfo
-    sys.last_exc = val
     seen = set()
 
     def print_exc(typ, exc, tb):
@@ -630,7 +629,6 @@ class Executive:
             flist = self.rpchandler.get_remote_proxy(flist_oid)
         while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
             tb = tb.tb_next
-        sys.last_exc = val
         sys.last_type = typ
         sys.last_value = val
         item = stackviewer.StackTreeItem(flist, tb)
index 702fd32ca5d1bdf8bef53ef64daa7c389bef30c1..94ffb4eff4dd26e8e20298100bd886884c534b91 100644 (file)
@@ -27,10 +27,7 @@ class StackTreeItem(TreeItem):
 
     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
@@ -40,15 +37,11 @@ class StackTreeItem(TreeItem):
         return stack
 
     def get_exception(self):
-        if hasattr(sys, 'last_exc'):
-            typ = 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
@@ -143,7 +136,6 @@ def _stack_viewer(parent):  # htest #
     except NameError:
         exc_type, exc_value, exc_tb = sys.exc_info()
     # inject stack trace to sys
-    sys.last_exc = exc_value
     sys.last_type = exc_type
     sys.last_value = exc_value
     sys.last_traceback = exc_tb
@@ -151,7 +143,6 @@ def _stack_viewer(parent):  # htest #
     StackBrowser(top, flist=flist, top=top, tb=exc_tb)
 
     # restore sys to original state
-    del sys.last_exc
     del sys.last_type
     del sys.last_value
     del sys.last_traceback