Commit 126c879b authored by Georg Brandl's avatar Georg Brandl

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

parent 236f7979
...@@ -1922,8 +1922,12 @@ class ModuleScanner: ...@@ -1922,8 +1922,12 @@ class ModuleScanner:
if key is None: if key is None:
callback(None, modname, '') callback(None, modname, '')
else: else:
try:
loader = importer.find_module(modname) 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: try:
source = loader.get_source(modname) source = loader.get_source(modname)
except UnicodeDecodeError: except UnicodeDecodeError:
...@@ -1932,7 +1936,7 @@ class ModuleScanner: ...@@ -1932,7 +1936,7 @@ class ModuleScanner:
continue continue
import io import io
desc = source_synopsis(io.StringIO(source)) or '' desc = source_synopsis(io.StringIO(source)) or ''
if hasattr(loader,'get_filename'): if hasattr(loader, 'get_filename'):
path = loader.get_filename(modname) path = loader.get_filename(modname)
else: else:
path = None path = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment