Utilities/ClassBrowsers/pyclbr.py

changeset 45
9a18f4dbb493
parent 13
1af94a91f439
child 97
c4086afea02b
--- a/Utilities/ClassBrowsers/pyclbr.py	Sun Jan 10 13:59:15 2010 +0000
+++ b/Utilities/ClassBrowsers/pyclbr.py	Sun Jan 10 19:19:52 2010 +0000
@@ -236,9 +236,10 @@
         path = [file] + path
         f, file, (suff, mode, type) = \
                         ClassBrowsers.find_module('__init__', [file])
+    if f:
+        f.close()
     if type not in SUPPORTED_TYPES:
         # not Python source, can't do anything with this module
-        f.close()
         _modules[module] = dict
         return dict
 
@@ -248,8 +249,12 @@
     deltastack = []
     deltaindent = 0
     deltaindentcalculated = 0
-    src = f.read()
-    f.close()
+    try:
+        src = Utilities.readEncodedFile(file)[0]
+    except (UnicodeError, IOError):
+        # can't do anything with this module
+        _modules[module] = dict
+        return dict
 
     lineno, last_lineno_pos = 1, 0
     i = 0

eric ide

mercurial