From 4f364a30bc6e3df96cf8e1d7dd1a0d2115c30f0b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Jul 2021 14:48:30 +0900 Subject: [PATCH] Fix #9436, #9471: autodoc: crashed if autodoc_class_signature = "separated" A list should be used for special-members option instead of set. --- CHANGES | 1 + sphinx/ext/autodoc/__init__.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b4ebcf49826..7a719096133 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ Bugs fixed with the HEAD of 3.10 * #9490: autodoc: Some objects under ``typing`` module are not displayed well with the HEAD of 3.10 +* #9436, #9471: autodoc: crashed if ``autodoc_class_signature = "separated"`` * #9435: linkcheck: Failed to check anchors in github.com Testing diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 1cecb1f797d..70d6ddc16bc 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -257,6 +257,9 @@ def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: L # But we define this class here to keep compatibility (see #4538) class Options(dict): """A dict/attribute hybrid that returns None on nonexisting keys.""" + def copy(self) -> "Options": + return Options(super().copy()) + def __getattr__(self, name: str) -> Any: try: return self[name.replace('_', '-')] @@ -1445,9 +1448,11 @@ def __init__(self, *args: Any) -> None: super().__init__(*args) if self.config.autodoc_class_signature == 'separated': + self.options = self.options.copy() + # show __init__() method if self.options.special_members is None: - self.options['special-members'] = {'__new__', '__init__'} + self.options['special-members'] = ['__new__', '__init__'] else: self.options.special_members.append('__new__') self.options.special_members.append('__init__')