Skip to content

Commit

Permalink
Merge branch '8084_KeyError_for_broken_class' into 3.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Aug 10, 2020
2 parents 51332c7 + f7431b9 commit bf26080
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -38,6 +38,8 @@ Bugs fixed
----------

* #8074: napoleon: Crashes during processing C-ext module
* #8084: autodoc: KeyError is raised on documenting an attribute of the broken
class

Testing
--------
Expand Down
6 changes: 6 additions & 0 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1610,6 +1610,9 @@ def add_directive_header(self, sig: str) -> None:
annotations = get_type_hints(self.parent)
except TypeError:
annotations = {}
except KeyError:
# a broken class found (refs: https://github.com/sphinx-doc/sphinx/issues/8084)
annotations = {}

if self.objpath[-1] in annotations:
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
Expand Down Expand Up @@ -1980,6 +1983,9 @@ def add_directive_header(self, sig: str) -> None:
annotations = get_type_hints(self.parent)
except TypeError:
annotations = {}
except KeyError:
# a broken class found (refs: https://github.com/sphinx-doc/sphinx/issues/8084)
annotations = {}

if self.objpath[-1] in annotations:
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
Expand Down

0 comments on commit bf26080

Please sign in to comment.