Skip to content

Commit

Permalink
Fix sphinx-doc#9436, sphinx-doc#9471: autodoc: crashed if autodoc_cla…
Browse files Browse the repository at this point in the history
…ss_signature = "separated"

A list should be used for special-members option instead of set.
  • Loading branch information
tk0miya committed Jul 24, 2021
1 parent 9218ad4 commit 4f364a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion sphinx/ext/autodoc/__init__.py
Expand Up @@ -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('_', '-')]
Expand Down Expand Up @@ -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__')
Expand Down

0 comments on commit 4f364a3

Please sign in to comment.