#5453: fix SyntaxErrors using pydoc -k, caused by intentionally bad files in Pythons test suite.

This commit is contained in:
Georg Brandl 2009-04-05 15:05:48 +00:00
parent 236f7979ba
commit 126c879b40
1 changed files with 7 additions and 3 deletions

View File

@ -1922,8 +1922,12 @@ class ModuleScanner:
if key is None:
callback(None, modname, '')
else:
try:
loader = importer.find_module(modname)
if hasattr(loader,'get_source'):
except SyntaxError:
# raised by tests for bad coding cookies or BOM
continue
if hasattr(loader, 'get_source'):
try:
source = loader.get_source(modname)
except UnicodeDecodeError:
@ -1932,7 +1936,7 @@ class ModuleScanner:
continue
import io
desc = source_synopsis(io.StringIO(source)) or ''
if hasattr(loader,'get_filename'):
if hasattr(loader, 'get_filename'):
path = loader.get_filename(modname)
else:
path = None