#1674: do not crash if module.__all__ is not according to spec

This commit is contained in:
Georg Brandl
2015-01-15 08:26:40 +01:00
parent ddb7c9945d
commit 5bee0aac0c
2 changed files with 10 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ Bugs fixed
* #1585: Autosummary of modules broken in Sphinx-1.2.3.
* #1610: Sphinx cause AttributeError when MeCab search option is enabled and
python-mecab is not installed.
* #1674: Do not crash if a module's ``__all__`` is not a list of strings.
Release 1.2.3 (released Sep 1, 2014)

View File

@@ -828,6 +828,15 @@ class ModuleDocumenter(Documenter):
return True, safe_getmembers(self.object)
else:
memberlist = self.object.__all__
# Sometimes __all__ is broken...
if not isinstance(memberlist, (list, tuple)) or not \
all(isinstance(entry, str) for entry in memberlist):
self.directive.warn(
'__all__ should be a list of strings, not %r '
'(in module %s) -- ignoring __all__' %
(memberlist, self.fullname))
# fall back to all members
return True, safe_getmembers(self.object)
else:
memberlist = self.options.members or []
ret = []