[Python-checkins] python/dist/src/Tools/scripts trace.py,1.6,1.7
montanaro@users.sourceforge.net
montanaro@users.sourceforge.net
Thu, 25 Jul 2002 09:09:37 -0700
Update of /cvsroot/python/python/dist/src/Tools/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv338
Modified Files:
trace.py
Log Message:
* runctx - fix a couple typos
* globaltrace_lt - handle case where inspect.getmodulename doesn't return
anything useful
* localtrace_trace - handle case where inspect.getframeinfo doesn't return
any context info
I think both of the last two are caused by exec'd or eval'd code
Index: trace.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/trace.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** trace.py 28 Nov 2001 19:41:45 -0000 1.6
--- trace.py 25 Jul 2002 16:09:35 -0000 1.7
***************
*** 501,507 ****
if locals is None: locals = {}
if not self.donothing:
! sys.settrace(gself.lobaltrace)
try:
! exec cmd in dict, dict
finally:
if not self.donothing:
--- 501,507 ----
if locals is None: locals = {}
if not self.donothing:
! sys.settrace(self.globaltrace)
try:
! exec cmd in globals, locals
finally:
if not self.donothing:
***************
*** 541,554 ****
if filename:
modulename = inspect.getmodulename(filename)
! ignore_it = self.ignore.names(filename, modulename)
! # if DEBUG_MODE and not self.blabbed.has_key((filename, modulename,)):
! # self.blabbed[(filename, modulename,)] = None
! # print "%s.globaltrace(frame: %s, why: %s, arg: %s, filename: %s, modulename: %s, ignore_it: %s\n" % (self, frame, why, arg, filename, modulename, ignore_it,)
! if not ignore_it:
! if self.trace:
! print " --- modulename: %s, funcname: %s" % (modulename, funcname,)
! # if DEBUG_MODE:
! # print "%s.globaltrace(frame: %s, why: %s, arg: %s, filename: %s, modulename: %s, ignore_it: %s -- about to localtrace\n" % (self, frame, why, arg, filename, modulename, ignore_it,)
! return self.localtrace
else:
# XXX why no filename?
--- 541,555 ----
if filename:
modulename = inspect.getmodulename(filename)
! if modulename is not None:
! ignore_it = self.ignore.names(filename, modulename)
! # if DEBUG_MODE and not self.blabbed.has_key((filename, modulename,)):
! # self.blabbed[(filename, modulename,)] = None
! # print "%s.globaltrace(frame: %s, why: %s, arg: %s, filename: %s, modulename: %s, ignore_it: %s\n" % (self, frame, why, arg, filename, modulename, ignore_it,)
! if not ignore_it:
! if self.trace:
! print " --- modulename: %s, funcname: %s" % (modulename, funcname,)
! # if DEBUG_MODE:
! # print "%s.globaltrace(frame: %s, why: %s, arg: %s, filename: %s, modulename: %s, ignore_it: %s -- about to localtrace\n" % (self, frame, why, arg, filename, modulename, ignore_it,)
! return self.localtrace
else:
# XXX why no filename?
***************
*** 587,595 ****
# Using setdefault faster than two separate lines? --Zooko 2001-10-14
bname = self.pathtobasename.setdefault(filename, os.path.basename(filename))
! try:
! print "%s(%d): %s" % (bname, lineno, context[lineindex],),
! except IndexError:
! # Uh.. sometimes getframeinfo gives me a context of length 1 and a lineindex of -2. Oh well.
! pass
return self.localtrace
--- 588,599 ----
# Using setdefault faster than two separate lines? --Zooko 2001-10-14
bname = self.pathtobasename.setdefault(filename, os.path.basename(filename))
! if context is not None:
! try:
! print "%s(%d): %s" % (bname, lineno, context[lineindex],),
! except IndexError:
! # Uh.. sometimes getframeinfo gives me a context of length 1 and a lineindex of -2. Oh well.
! pass
! else:
! print "%s(???): ???" % bname
return self.localtrace