Skip to content

Commit a0f3d0e

Browse files
committed
bpo-46353: Fix "pydoc -k" when a module fails to load
The 'spec' value, here coming from pkgutil._get_spec(), may be None because <importer>.find_module() may return None. We account for this in pydoc's ModuleScanner and skip such modules scan.
1 parent be578e0 commit a0f3d0e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/pydoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,8 @@ def run(self, callback, key=None, completer=None, onerror=None):
22302230
except SyntaxError:
22312231
# raised by tests for bad coding cookies or BOM
22322232
continue
2233+
if spec is None:
2234+
continue
22332235
loader = spec.loader
22342236
if hasattr(loader, 'get_source'):
22352237
try:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Skip scan of modules that fail to load during keyword search in
2+
:mod:`pydoc`.

0 commit comments

Comments
 (0)