fix pydoc.apropos and pydoc.synopsis on modules with empty docstrings (#21548)
Patch by Yuyang Guo and Berker Peksag.
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index d53a1b4..d37ebf1 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -270,7 +270,7 @@
except:
return None
del sys.modules['__temp__']
- result = (module.__doc__ or '').splitlines()[0]
+ result = module.__doc__.splitlines()[0] if module.__doc__ else None
# Cache the result.
cache[filename] = (mtime, result)
return result
@@ -2075,7 +2075,7 @@
if onerror:
onerror(modname)
continue
- desc = (module.__doc__ or '').splitlines()[0]
+ desc = module.__doc__.splitlines()[0] if module.__doc__ else ''
path = getattr(module,'__file__',None)
name = modname + ' - ' + desc
if name.lower().find(key) >= 0: