Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.

Original patch by John Mark Vandenberg.
This commit is contained in:
Serhiy Storchaka 2015-10-29 08:17:10 +02:00
commit 6230235e83
5 changed files with 19 additions and 9 deletions

View file

@ -527,17 +527,18 @@ def _finddoc(obj):
cls = self
else:
cls = self.__class__
# Should be tested before isdatadescriptor().
elif isinstance(obj, property):
func = obj.fget
name = func.__name__
cls = _findclass(func)
if cls is None or getattr(cls, name) is not obj:
return None
elif ismethoddescriptor(obj) or isdatadescriptor(obj):
name = obj.__name__
cls = obj.__objclass__
if getattr(cls, name) is not obj:
return None
elif isinstance(obj, property):
func = f.fget
name = func.__name__
cls = _findclass(func)
if cls is None or getattr(cls, name) is not obj:
return None
else:
return None