From da4f091c211ccf30a8a7591c4881027fe1d74c35 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sat, 24 Oct 2020 20:55:06 +0200 Subject: [PATCH] autodoc: check whether __slots__ is a str Closes #8294. --- sphinx/ext/autodoc/importer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 133ce1439c9..52b07639af6 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -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: 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) # other members