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.
This commit is contained in:
Takeshi KOMIYA
2020-08-09 00:44:04 +09:00
parent 40bdeb2c16
commit 51332c7b08
2 changed files with 6 additions and 1 deletions

View File

@@ -37,6 +37,8 @@ Features added
Bugs fixed
----------
* #8074: napoleon: Crashes during processing C-ext module
Testing
--------

View File

@@ -1074,7 +1074,10 @@ class NumpyDocstring(GoogleDocstring):
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: