diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 7d52359c9a0ce9..4014a2f54a5549 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2230,6 +2230,8 @@ def run(self, callback, key=None, completer=None, onerror=None): except SyntaxError: # raised by tests for bad coding cookies or BOM continue + if spec is None: + continue loader = spec.loader if hasattr(loader, 'get_source'): try: diff --git a/Misc/NEWS.d/next/Library/2022-01-12-14-10-42.bpo-46353.wSHF5T.rst b/Misc/NEWS.d/next/Library/2022-01-12-14-10-42.bpo-46353.wSHF5T.rst new file mode 100644 index 00000000000000..cfc77f35318325 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-12-14-10-42.bpo-46353.wSHF5T.rst @@ -0,0 +1,2 @@ +Skip scan of modules that fail to load during keyword search in +:mod:`pydoc`.