]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix pydoc.synopsis() so that it doesn't error out with an unreadable
authorGeorg Brandl <georg@python.org>
Wed, 8 Mar 2006 09:34:57 +0000 (09:34 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 8 Mar 2006 09:34:57 +0000 (09:34 +0000)
module.
 (backport from rev. 42912)

Lib/pydoc.py

index 056982699a6d2198d2f2b53bad2e041a940f9471..fca4e09551254e31e997687eb5e730d023b365f1 100755 (executable)
@@ -179,7 +179,11 @@ def synopsis(filename, cache={}):
     lastupdate, result = cache.get(filename, (0, None))
     if lastupdate < mtime:
         info = inspect.getmoduleinfo(filename)
-        file = open(filename)
+        try:
+            file = open(filename)
+        except IOError:
+            # module can't be opened, so skip it
+            return None
         if info and 'b' in info[2]: # binary modules have to be imported
             try: module = imp.load_module('__temp__', file, filename, info[1:])
             except: return None