summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc.py
diff options
context:
space:
mode:
authorTatiana Tereshchenko <ttereshc@redhat.com>2017-05-22 03:24:37 +0200
committerTatiana Tereshchenko <ttereshc@redhat.com>2017-05-24 11:46:47 +0200
commitdfc719e187d251c758606ba8d7fe2cd8069304b6 (patch)
tree2c6510db8fcb1fb42604f7b1fd4340e2139b29e9 /sphinx/ext/autodoc.py
parenta408e5bb2f0c557eb97407bcfcd56b3cff31f6a8 (diff)
downloadsphinx-git-dfc719e187d251c758606ba8d7fe2cd8069304b6.tar.gz
Fix #3779: 'ImportError' in sphinx.ext.autodoc due to broken 'sys.meta_path'
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r--sphinx/ext/autodoc.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 1b314bd0e..c50b55387 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -171,13 +171,12 @@ class _MockImporter(object):
# set(['a', 'd'])
self.base_packages.add(n.split('.')[0])
self.mocked_modules = [] # type: List[str]
- self.orig_meta_path = sys.meta_path
# enable hook by adding itself to meta_path
sys.meta_path = sys.meta_path + [self]
def disable(self):
- # restore original meta_path to disable import hook
- sys.meta_path = self.orig_meta_path
+ # remove `self` from `sys.meta_path` to disable import hook
+ sys.meta_path = [i for i in sys.meta_path if i is not self]
# remove mocked modules from sys.modules to avoid side effects after
# running auto-documenter
for m in self.mocked_modules: