Skip to content

Commit 4f364a3

Browse files
committed
Fix #9436, #9471: autodoc: crashed if autodoc_class_signature = "separated"
A list should be used for special-members option instead of set.
1 parent 9218ad4 commit 4f364a3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Bugs fixed
2323
with the HEAD of 3.10
2424
* #9490: autodoc: Some objects under ``typing`` module are not displayed well
2525
with the HEAD of 3.10
26+
* #9436, #9471: autodoc: crashed if ``autodoc_class_signature = "separated"``
2627
* #9435: linkcheck: Failed to check anchors in github.com
2728

2829
Testing

sphinx/ext/autodoc/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: L
257257
# But we define this class here to keep compatibility (see #4538)
258258
class Options(dict):
259259
"""A dict/attribute hybrid that returns None on nonexisting keys."""
260+
def copy(self) -> "Options":
261+
return Options(super().copy())
262+
260263
def __getattr__(self, name: str) -> Any:
261264
try:
262265
return self[name.replace('_', '-')]
@@ -1445,9 +1448,11 @@ def __init__(self, *args: Any) -> None:
14451448
super().__init__(*args)
14461449

14471450
if self.config.autodoc_class_signature == 'separated':
1451+
self.options = self.options.copy()
1452+
14481453
# show __init__() method
14491454
if self.options.special_members is None:
1450-
self.options['special-members'] = {'__new__', '__init__'}
1455+
self.options['special-members'] = ['__new__', '__init__']
14511456
else:
14521457
self.options.special_members.append('__new__')
14531458
self.options.special_members.append('__init__')

0 commit comments

Comments
 (0)