diff options
author | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-07-05 00:11:59 +0900 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-07-05 00:11:59 +0900 |
commit | 4d69072f44352795573ca276a6aa6a4379bd9228 (patch) | |
tree | 0813f9ba0e4a9330c7337af311244456a4193f74 /sphinx/ext/autodoc.py | |
parent | b3aa4aa81bb7311136587c134f805b86d2435fb3 (diff) | |
download | sphinx-git-4d69072f44352795573ca276a6aa6a4379bd9228.tar.gz |
* Fix: autodoc, autosummary: importing setup.py will invoke setup process and execute `sys.exit()`. Now sphinx avoids SystemExit exception and emits warnings without unexpected termination. Closes #1226
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r-- | sphinx/ext/autodoc.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index b6343171e..423f921a2 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -347,15 +347,19 @@ class Documenter(object): return True # this used to only catch SyntaxError, ImportError and AttributeError, # but importing modules with side effects can raise all kinds of errors - except Exception: + except (Exception, SystemExit) as e: if self.objpath: errmsg = 'autodoc: failed to import %s %r from module %r' % \ (self.objtype, '.'.join(self.objpath), self.modname) else: errmsg = 'autodoc: failed to import %s %r' % \ (self.objtype, self.fullname) - errmsg += '; the following exception was raised:\n%s' % \ - traceback.format_exc() + if isinstance(e, SystemExit): + errmsg += ('; the module executes module level statement ' + + 'and it might call sys.exit().') + else: + errmsg += '; the following exception was raised:\n%s' % \ + traceback.format_exc() dbg(errmsg) self.directive.warn(errmsg) self.env.note_reread() |