summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-03-25 20:01:13 (GMT)
committerGitHub <noreply@github.com>2019-03-25 20:01:13 (GMT)
commitd1e768a67707bf7bb426c1537e1a764e89eaff78 (patch)
treeeba1dc9c8a257e8c9fec36cef006eb06498d54ee /Lib/inspect.py
parent713a8ae7926472b02ee1a394633eb54aaa7912d1 (diff)
downloadcpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.zip
cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.gz
cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.bz2
bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b8a1422..8c398bd 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -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__