autodoc: check whether __slots__ is a str

Closes #8294.
This commit is contained in:
Matthias Geier 2020-10-24 20:55:06 +02:00
parent 3b85187ffa
commit da4f091c21

View File

@ -206,7 +206,10 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
if isclass(subject) and getattr(subject, '__slots__', None) is not None: if isclass(subject) and getattr(subject, '__slots__', None) is not None:
from sphinx.ext.autodoc import SLOTSATTR from sphinx.ext.autodoc import SLOTSATTR
for name in subject.__slots__: slots = subject.__slots__
if isinstance(slots, str):
slots = [slots]
for name in slots:
members[name] = Attribute(name, True, SLOTSATTR) members[name] = Attribute(name, True, SLOTSATTR)
# other members # other members