diff options
| author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-03-25 13:01:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-25 13:01:13 -0700 |
| commit | d1e768a67707bf7bb426c1537e1a764e89eaff78 (patch) | |
| tree | eba1dc9c8a257e8c9fec36cef006eb06498d54ee /Lib/inspect.py | |
| parent | 713a8ae7926472b02ee1a394633eb54aaa7912d1 (diff) | |
| download | cpython-git-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.gz | |
bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)
Diffstat (limited to 'Lib/inspect.py')
| -rw-r--r-- | Lib/inspect.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index b8a142232b..8c398bd353 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__ |
