mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
fix pydoc.apropos and pydoc.synopsis on modules with empty docstrings (#21548)
Patch by Yuyang Guo and Berker Peksag.
This commit is contained in:
parent
3584056ca5
commit
54237f9fea
4 changed files with 38 additions and 2 deletions
|
@ -270,7 +270,7 @@ def synopsis(filename, cache={}):
|
|||
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 @@ class ModuleScanner:
|
|||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue