[Python-checkins] r42913 - python/branches/release24-maint/Lib/pydoc.py

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


Author: georg.brandl
Date: Wed Mar  8 10:34:57 2006
New Revision: 42913

Modified:
   python/branches/release24-maint/Lib/pydoc.py
Log:
Fix pydoc.synopsis() so that it doesn't error out with an unreadable
module.
 (backport from rev. 42912)

Modified: python/branches/release24-maint/Lib/pydoc.py
==============================================================================
--- python/branches/release24-maint/Lib/pydoc.py	(original)
+++ python/branches/release24-maint/Lib/pydoc.py	Wed Mar  8 10:34:57 2006
@@ -179,7 +179,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