[issue24790] Idle: improve stack viewer

Terry J. Reedy report at bugs.python.org
Tue Aug 18 19:10:43 CEST 2015


Terry J. Reedy added the comment:

StackViewer.py seem to be identical in 3.4, 3.5, and 3.6, so a patch against any applies to all.  The diff with 2.7 is

F:\Python\dev\36>hg diff -r 4884af6d3e30 f:/python/dev/36/Lib/idlelib/StackViewer.py
@@ -2,7 +2,7 @@
 import sys
 import linecache
 import re
-import Tkinter as tk
+import tkinter as tk

 from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
 from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem
@@ -10,7 +10,7 @@

 def StackBrowser(root, flist=None, tb=None, top=None):
     if top is None:
-        from Tkinter import Toplevel
+        from tkinter import Toplevel
         top = Toplevel(root)
     sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
     sc.frame.pack(expand=1, fill="both")
@@ -109,7 +109,7 @@
         return len(self.object) > 0

     def keys(self):
-        return self.object.keys()
+        return list(self.object.keys())

     def GetSubList(self):
         sublist = []

The second and third differences are due to unneeded code; I will remove them after I submit this message, so update your repository after I do that and then patch.

---
Your research is very helpful.  The purpose of 1. *is* to remove data ;-) -- data that is only present because of Idle.  The purpose of  StackTreeItem.get_stack is to removed unneeded data while converting a linked list to a regular list.  Note that the loop drops 2 of 4 fields. I do not know if
        if tb and tb.tb_frame is None:
            tb = tb.tb_next
actually removes anything, but after this, I believe that the idlelib.run.runcode node (or idlelib.PyShell.runcode node, when Idle is started with -n) is at the top of the linked list.  So I believe adding
        tb = tb.tb_next
after the above will do what we want.  Try it, and if it works, move on.

---
6 (modeled after 3). Modules only have +Globals.  Remove +Globals under each module and instead display globals when expanding. (There will only be a module other than __main__ when there is an error in another module being imported.  We should then improve the lines to read
  + Globals for module __main__ ...
  + Locals for function xyz...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24790>
_______________________________________


More information about the Python-bugs-list mailing list