[Python-checkins] CVS: python/dist/src/Lib linecache.py,1.7,1.8

Tim Peters tim_one@users.sourceforge.net
Mon, 28 May 2001 21:27:03 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv25825/python/dist/src/Lib

Modified Files:
	linecache.py 
Log Message:
Patch from Gordon McMillan.
updatecache():  When using imputil, sys.path may contain things other than
strings.  Ignore such things instead of blowing up.
Hard to say whether this is a bugfix or a feature ...


Index: linecache.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** linecache.py	2001/01/24 06:27:27	1.7
--- linecache.py	2001/05/29 04:27:01	1.8
***************
*** 70,82 ****
          stat = os.stat(fullname)
      except os.error, msg:
!         # Try looking through the module search path
          basename = os.path.split(filename)[1]
          for dirname in sys.path:
!             fullname = os.path.join(dirname, basename)
              try:
!                 stat = os.stat(fullname)
!                 break
!             except os.error:
                  pass
          else:
              # No luck
--- 70,89 ----
          stat = os.stat(fullname)
      except os.error, msg:
!         # Try looking through the module search path.
          basename = os.path.split(filename)[1]
          for dirname in sys.path:
!             # When using imputil, sys.path may contain things other than
!             # strings; ignore them when it happens.
              try:
!                 fullname = os.path.join(dirname, basename)
!             except (TypeError, AttributeError):
!                 # Not sufficiently string-like to do anything useful with.
                  pass
+             else:
+                 try:
+                     stat = os.stat(fullname)
+                     break
+                 except os.error:
+                     pass
          else:
              # No luck