]> granicus.if.org Git - python/commitdiff
Patch from Gordon McMillan.
authorTim Peters <tim.peters@gmail.com>
Tue, 29 May 2001 04:27:01 +0000 (04:27 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 29 May 2001 04:27:01 +0000 (04:27 +0000)
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 ...

Lib/linecache.py

index d6fc28cae301823c037af35bb3a3b26ab3b42697..cd3e50d27edde9e426fffe1e70a4554d013c6126 100644 (file)
@@ -69,15 +69,22 @@ def updatecache(filename):
     try:
         stat = os.stat(fullname)
     except os.error, msg:
-        # Try looking through the module search path
+        # Try looking through the module search path.
         basename = os.path.split(filename)[1]
         for dirname in sys.path:
-            fullname = os.path.join(dirname, basename)
+            # When using imputil, sys.path may contain things other than
+            # strings; ignore them when it happens.
             try:
-                stat = os.stat(fullname)
-                break
-            except os.error:
+                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
 ##          print '*** Cannot stat', filename, ':', msg