Skip to content

Commit 1567281

Browse files
authored
autodoc: Fix UnboundLocalError in filter_members (#11651)
1 parent 5e88b9f commit 1567281

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

sphinx/ext/autodoc/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,23 @@ def is_filtered_inherited_member(name: str, obj: Any) -> bool:
678678
try:
679679
membername = obj.__name__
680680
member = obj.object
681-
# if isattr is True, the member is documented as an attribute
682-
isattr = member is INSTANCEATTR or (namespace, membername) in attr_docs
681+
except AttributeError:
682+
if isinstance(obj, ObjectMember):
683+
raise
684+
# To be removed, retained for compatibility.
685+
# See https://github.com/sphinx-doc/sphinx/issues/11631
686+
membername, member = obj
687+
warnings.warn(
688+
'Returning tuples of (name, object) as '
689+
'the second return value from get_object_members() is deprecated. '
690+
'Return ObjectMember(name, object) instances instead.',
691+
RemovedInSphinx80Warning, stacklevel=2,
692+
)
693+
694+
# if isattr is True, the member is documented as an attribute
695+
isattr = member is INSTANCEATTR or (namespace, membername) in attr_docs
683696

697+
try:
684698
doc = getdoc(member, self.get_attr, self.config.autodoc_inherit_docstrings,
685699
self.object, membername)
686700
if not isinstance(doc, str):

0 commit comments

Comments
 (0)