[Idle-dev] CVS: idle PyShell.py,1.45,1.46
Kurt B. Kaiser
kbk@users.sourceforge.net
Mon, 23 Dec 2002 16:57:24 -0800
Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv25766
Modified Files:
PyShell.py
Log Message:
1. RPC stack levels were not pruned from traceback unless IDLE was started
from its source directory.
2. Replace final traceback '?' with '-toplevel-'
3. Remove duplicated import boolcheck
Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** PyShell.py 23 Dec 2002 18:11:26 -0000 1.45
--- PyShell.py 24 Dec 2002 00:57:22 -0000 1.46
***************
*** 13,18 ****
import exceptions
- import boolcheck
-
import linecache
from code import InteractiveInterpreter
--- 13,16 ----
***************
*** 218,222 ****
return lines
! # XXX 13 Dec 2020 KBK Not used currently
# def saved_change_hook(self):
# "Extend base method - clear breaks if module is modified"
--- 216,220 ----
return lines
! # XXX 13 Dec 2002 KBK Not used currently
# def saved_change_hook(self):
# "Extend base method - clear breaks if module is modified"
***************
*** 396,408 ****
mod, name, args, tb = what
print >>file, 'Traceback (most recent call last):'
! while tb and tb[0][0] in ("run.py", "rpc.py"):
! del tb[0]
! while tb and tb[-1][0] in ("run.py", "rpc.py"):
! del tb[-1]
! for i in range(len(tb)):
! fn, ln, nm, line = tb[i]
! if not line and fn.startswith("<pyshell#"):
! line = linecache.getline(fn, ln)
! tb[i] = fn, ln, nm, line
traceback.print_list(tb, file=file)
# try to reinstantiate the exception, stuff in the args:
--- 394,399 ----
mod, name, args, tb = what
print >>file, 'Traceback (most recent call last):'
! exclude = ("run.py", "rpc.py")
! self.cleanup_traceback(tb, exclude)
traceback.print_list(tb, file=file)
# try to reinstantiate the exception, stuff in the args:
***************
*** 425,428 ****
--- 416,443 ----
print >>file, errmsg, what
self.tkconsole.endexecuting()
+
+ def cleanup_traceback(self, tb, exclude):
+ "Remove excluded traces from beginning/end of tb; get cached lines"
+ while tb:
+ for rpcfile in exclude:
+ if tb[0][0].count(rpcfile):
+ break # found an exclude, break for: and delete tb[0]
+ else:
+ break # no excludes, have left RPC code, break while:
+ del tb[0]
+ while tb:
+ for rpcfile in exclude:
+ if tb[-1][0].count(rpcfile):
+ break
+ else:
+ break
+ del tb[-1]
+ for i in range(len(tb)):
+ fn, ln, nm, line = tb[i]
+ if nm == '?':
+ nm = "-toplevel-"
+ if not line and fn.startswith("<pyshell#"):
+ line = linecache.getline(fn, ln)
+ tb[i] = fn, ln, nm, line
def kill_subprocess(self):