[Idle-dev] CVS: idle StackViewer.py,1.6,1.7
Kurt B. Kaiser
kbk@users.sourceforge.net
Sun, 01 Dec 2002 21:08:56 -0800
Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv641
Modified Files:
StackViewer.py
Log Message:
Remove dead code in get_stack().
Modify get_stack() and get_exception to be StackTreeItem methods.
SF Bug 610756. Neal Norwitz.
Index: StackViewer.py
===================================================================
RCS file: /cvsroot/idlefork/idle/StackViewer.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** StackViewer.py 18 Sep 2002 03:15:56 -0000 1.6
--- StackViewer.py 2 Dec 2002 05:08:54 -0000 1.7
***************
*** 20,25 ****
def __init__(self, flist=None, tb=None):
self.flist = flist
! self.stack = get_stack(tb)
! self.text = get_exception()
def GetText(self):
--- 20,46 ----
def __init__(self, flist=None, tb=None):
self.flist = flist
! 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):
***************
*** 55,60 ****
item = "%s.%s(...), line %d: %s" % (modname, funcname,
lineno, sourceline)
- ## if i == index:
- ## item = "> " + item
return item
--- 76,79 ----
***************
*** 103,133 ****
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():
--- 122,125 ----