[Python-checkins] r42912 - python/trunk/Lib/pydoc.py

georg.brandl python-checkins at python.org
Wed Mar 8 10:34:54 CET 2006


Author: georg.brandl
Date: Wed Mar  8 10:34:53 2006
New Revision: 42912

Modified:
   python/trunk/Lib/pydoc.py
Log:
Fix pydoc.synopsis() so that it doesn't error out with an unreadable
module.


Modified: python/trunk/Lib/pydoc.py
==============================================================================
--- python/trunk/Lib/pydoc.py	(original)
+++ python/trunk/Lib/pydoc.py	Wed Mar  8 10:34:53 2006
@@ -188,7 +188,11 @@
     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


More information about the Python-checkins mailing list