bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)

This commit is contained in:
Raymond Hettinger 2019-03-25 13:01:13 -07:00 committed by GitHub
parent 713a8ae792
commit d1e768a677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 3 deletions

View file

@ -582,9 +582,12 @@ def _finddoc(obj):
cls = obj.__objclass__
if getattr(cls, name) is not obj:
return None
if ismemberdescriptor(obj):
slots = getattr(cls, '__slots__', None)
if isinstance(slots, dict) and name in slots:
return slots[name]
else:
return None
for base in cls.__mro__:
try:
doc = getattr(base, name).__doc__