Skip to content

Commit 26fd2e1

Browse files
committed
Fix pydoc.synopsis() so that it doesn't error out with an unreadable
module.
1 parent 2f5e990 commit 26fd2e1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/pydoc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ def synopsis(filename, cache={}):
188188
lastupdate, result = cache.get(filename, (0, None))
189189
if lastupdate < mtime:
190190
info = inspect.getmoduleinfo(filename)
191-
file = open(filename)
191+
try:
192+
file = open(filename)
193+
except IOError:
194+
# module can't be opened, so skip it
195+
return None
192196
if info and 'b' in info[2]: # binary modules have to be imported
193197
try: module = imp.load_module('__temp__', file, filename, info[1:])
194198
except: return None

0 commit comments

Comments
 (0)