From 51332c7b08f17a471706aa3a2b5a55d34c28a31d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 9 Aug 2020 00:44:04 +0900 Subject: [PATCH] Fix #8074: napoleon: Crashes during processing C-ext module inspect.getfile() raises TypeError if given object is a C-extension. This handles the exception not to be crashed. --- CHANGES | 2 ++ sphinx/ext/napoleon/docstring.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5f645efa843..0926737463b 100644 --- a/CHANGES +++ b/CHANGES @@ -37,6 +37,8 @@ Features added Bugs fixed ---------- +* #8074: napoleon: Crashes during processing C-ext module + Testing -------- diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 52abf975339..29799cb06c3 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -1074,7 +1074,10 @@ def __init__(self, docstring: Union[str, List[str]], config: SphinxConfig = None super().__init__(docstring, config, app, what, name, obj, options) def _get_location(self) -> str: - filepath = inspect.getfile(self._obj) if self._obj is not None else None + try: + filepath = inspect.getfile(self._obj) if self._obj is not None else None + except TypeError: + filepath = None name = self._name if filepath is None and name is None: