summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/StackViewer.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2002-12-02 05:08:54 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2002-12-02 05:08:54 (GMT)
commit5f7c4b34b91171da1755af9b6bf69eda07b811aa (patch)
tree807fee8805b9e6be3b5043447b0b59d16d95d4c3 /Lib/idlelib/StackViewer.py
parent75bc8ba0d7d445bd85ba0f3d79d355d46704bb81 (diff)
downloadcpython-5f7c4b34b91171da1755af9b6bf69eda07b811aa.zip
cpython-5f7c4b34b91171da1755af9b6bf69eda07b811aa.tar.gz
cpython-5f7c4b34b91171da1755af9b6bf69eda07b811aa.tar.bz2
Remove dead code in get_stack().
Modify get_stack() and get_exception to be StackTreeItem methods. SF Bug 610756. Neal Norwitz.
Diffstat (limited to 'Lib/idlelib/StackViewer.py')
-rw-r--r--Lib/idlelib/StackViewer.py54
1 files changed, 23 insertions, 31 deletions
diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/StackViewer.py
index 5807707..6b7730b 100644
--- a/Lib/idlelib/StackViewer.py
+++ b/Lib/idlelib/StackViewer.py
@@ -19,8 +19,29 @@ class StackTreeItem(TreeItem):
def __init__(self, flist=None, tb=None):
self.flist = flist
- self.stack = get_stack(tb)
- self.text = get_exception()
+ self.stack = self.get_stack(tb)
+ self.text = self.get_exception()
+
+ def get_stack(self, tb):
+ if tb is None:
+ tb = sys.last_traceback
+ stack = []
+ if tb and tb.tb_frame is None:
+ tb = tb.tb_next
+ while tb is not None:
+ stack.append((tb.tb_frame, tb.tb_lineno))
+ tb = tb.tb_next
+ return stack
+
+ def get_exception(self):
+ 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
def GetText(self):
return self.text
@@ -54,8 +75,6 @@ class FrameTreeItem(TreeItem):
else:
item = "%s.%s(...), line %d: %s" % (modname, funcname,
lineno, sourceline)
-## if i == index:
-## item = "> " + item
return item
def GetSubList(self):
@@ -102,33 +121,6 @@ class VariablesTreeItem(ObjectTreeItem):
sublist.append(item)
return sublist
-def get_stack(t=None, f=None):
- if t is None:
- t = sys.last_traceback
- stack = []
- if t and t.tb_frame is f:
- t = t.tb_next
- while f is not None:
- stack.append((f, f.f_lineno))
- if f is self.botframe:
- break
- f = f.f_back
- stack.reverse()
- while t is not None:
- stack.append((t.tb_frame, t.tb_lineno))
- t = t.tb_next
- return stack
-
-def get_exception(type=None, value=None):
- if type is None:
- 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
def _test():
try: