diff options
author | Georg Brandl <georg@python.org> | 2009-04-05 15:05:48 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-04-05 15:05:48 (GMT) |
commit | 126c879b406f24363bdfccffa16e62acc695aea1 (patch) | |
tree | 8ba3844b219840d8056d63a56e2e50ecee3c68ef /Lib | |
parent | 236f7979ba99430710bc249446a343195e252010 (diff) | |
download | cpython-126c879b406f24363bdfccffa16e62acc695aea1.zip cpython-126c879b406f24363bdfccffa16e62acc695aea1.tar.gz cpython-126c879b406f24363bdfccffa16e62acc695aea1.tar.bz2 |
#5453: fix SyntaxErrors using pydoc -k, caused by intentionally bad files in Pythons test suite.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/pydoc.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 2aea8c0..f68e72a 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1922,8 +1922,12 @@ class ModuleScanner: if key is None: callback(None, modname, '') else: - loader = importer.find_module(modname) - if hasattr(loader,'get_source'): + try: + loader = importer.find_module(modname) + 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 |