[Python-checkins] CVS: python/dist/src/Lib inspect.py,1.28,1.29
Neil Schemenauer
nascheme@users.sourceforge.net
Sat, 23 Mar 2002 15:51:06 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15457/Lib
Modified Files:
inspect.py
Log Message:
Use linecache for loading source code. Closes SF patch 490374.
Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** inspect.py 17 Mar 2002 18:56:20 -0000 1.28
--- inspect.py 23 Mar 2002 23:51:04 -0000 1.29
***************
*** 28,32 ****
__date__ = '1 Jan 2001'
! import sys, os, types, string, re, dis, imp, tokenize
# ----------------------------------------------------------- type-checking
--- 28,32 ----
__date__ = '1 Jan 2001'
! import sys, os, types, string, re, dis, imp, tokenize, linecache
# ----------------------------------------------------------- type-checking
***************
*** 382,391 ****
in the file and the line number indexes a line in that list. An IOError
is raised if the source code cannot be retrieved."""
! try:
! file = open(getsourcefile(object))
! except (TypeError, IOError):
raise IOError, 'could not get source code'
- lines = file.readlines()
- file.close()
if ismodule(object):
--- 382,389 ----
in the file and the line number indexes a line in that list. An IOError
is raised if the source code cannot be retrieved."""
! file = getsourcefile(object) or getfile(object)
! lines = linecache.getlines(file)
! if not lines:
raise IOError, 'could not get source code'
if ismodule(object):
***************
*** 707,711 ****
raise TypeError, 'arg is not a frame or traceback object'
! filename = getsourcefile(frame)
lineno = getlineno(frame)
if context > 0:
--- 705,709 ----
raise TypeError, 'arg is not a frame or traceback object'
! filename = getsourcefile(frame) or getfile(frame)
lineno = getlineno(frame)
if context > 0: