mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
* 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
This commit is contained in:
parent
b3aa4aa81b
commit
4d69072f44
3
CHANGES
3
CHANGES
@ -18,6 +18,9 @@ Bugs fixed
|
||||
* #1499: With non-callable `setup` in a conf.py, now sphinx-build emits
|
||||
user-friendly error message.
|
||||
* #1502: In autodoc, fix display of parameter defaults containing backslashes.
|
||||
* #1226: autodoc, autosummary: importing setup.py by automodule will invoke
|
||||
setup process and execute `sys.exit()`. Now sphinx avoids SystemExit
|
||||
exception and emits warnings without unexpected termination.
|
||||
|
||||
Release 1.2.2 (released Mar 2, 2014)
|
||||
====================================
|
||||
|
@ -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()
|
||||
|
@ -242,6 +242,9 @@ def find_autosummary_in_docstring(name, module=None, filename=None):
|
||||
pass
|
||||
except ImportError, e:
|
||||
print "Failed to import '%s': %s" % (name, e)
|
||||
except SystemExit, e:
|
||||
print("Failed to import '%s'; the module executes module level "
|
||||
"statement and it might call sys.exit()." % name)
|
||||
return []
|
||||
|
||||
def find_autosummary_in_lines(lines, module=None, filename=None):
|
||||
|
Loading…
Reference in New Issue
Block a user