summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-12 23:09:44 +0900
committerGitHub <noreply@github.com>2020-11-12 23:09:44 +0900
commit5cabdecb9e47c50fd7de32f02acef1ddfde3b1cf (patch)
tree66a6833cc164f7f57de9837523ef8fa558da987a
parentde2d2cc6ac7e381a4d4dacac146d09cb8e4e0c18 (diff)
parent953a5ec89801edb7047a779bc443b40acf066a27 (diff)
downloadsphinx-git-5cabdecb9e47c50fd7de32f02acef1ddfde3b1cf.tar.gz
Merge pull request #8412 from tk0miya/8164_autosummary_mock_imports_causes_slowdown
Fix #8350: autosummary_mock_imports causes slow down builds
-rw-r--r--CHANGES1
-rw-r--r--sphinx/util/inspect.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 5e30dc7ed..eb041082f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index f2cd8070b..9f5bf785e 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -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