Merge pull request #8412 from tk0miya/8164_autosummary_mock_imports_causes_slowdown

Fix #8350: autosummary_mock_imports causes slow down builds
This commit is contained in:
Takeshi KOMIYA
2020-11-12 23:09:44 +09:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ Bugs fixed
* #8372: autodoc: autoclass directive became slower than Sphinx-3.2
* #7727: autosummary: raise PycodeError when documenting python package
without __init__.py
* #8350: autosummary: autosummary_mock_imports causes slow down builds
* #8364: C, properly initialize attributes in empty symbols.
* #8399: i18n: Put system locale path after the paths specified by configuration

View File

@@ -122,7 +122,11 @@ def getargspec(func: Callable) -> Any:
def unwrap(obj: Any) -> Any:
"""Get an original object from wrapped object (wrapped functions)."""
try:
return inspect.unwrap(obj)
if hasattr(obj, '__sphinx_mock__'):
# Skip unwrapping mock object to avoid RecursionError
return obj
else:
return inspect.unwrap(obj)
except ValueError:
# might be a mock object
return obj