summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc/importer.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-21 01:01:36 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-21 01:01:36 +0900
commit3a4ae2092a6f236e2d71fdedb4b66f594e30d4e7 (patch)
treeafa4f774e0f8660d5ce247f01cace9deaa848d58 /sphinx/ext/autodoc/importer.py
parentf3a6004f822b05e352372a77f449332ad230d21e (diff)
parent18b2707b2ac621f23f8ee6a7ca19bf1590be7826 (diff)
downloadsphinx-git-3a4ae2092a6f236e2d71fdedb4b66f594e30d4e7.tar.gz
Merge branch '3.x'
Diffstat (limited to 'sphinx/ext/autodoc/importer.py')
-rw-r--r--sphinx/ext/autodoc/importer.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py
index df5614f99..e61874c47 100644
--- a/sphinx/ext/autodoc/importer.py
+++ b/sphinx/ext/autodoc/importer.py
@@ -15,7 +15,7 @@ from typing import Any, Callable, Dict, List, Mapping, NamedTuple, Optional, Tup
from sphinx.pycode import ModuleAnalyzer
from sphinx.util import logging
-from sphinx.util.inspect import isclass, isenumclass, safe_getattr
+from sphinx.util.inspect import getslots, isclass, isenumclass, safe_getattr
if False:
# For type annotation
@@ -203,14 +203,15 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
members[name] = Attribute(name, True, value)
# members in __slots__
- if isclass(subject) and getattr(subject, '__slots__', None) is not None:
- from sphinx.ext.autodoc import SLOTSATTR
-
- slots = subject.__slots__
- if isinstance(slots, str):
- slots = [slots]
- for name in slots:
- members[name] = Attribute(name, True, SLOTSATTR)
+ try:
+ __slots__ = getslots(subject)
+ if __slots__:
+ from sphinx.ext.autodoc import SLOTSATTR
+
+ for name in __slots__:
+ members[name] = Attribute(name, True, SLOTSATTR)
+ except (TypeError, ValueError):
+ pass
# other members
for name in dir(subject):