From 69f7e0768114fde9ccabc4bf7d56f765743612a6 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 23 Sep 2011 10:46:43 +0200 Subject: [PATCH] Fix #627: Fix tracebacks for AttributeErrors in autosummary generation. --- CHANGES | 2 ++ sphinx/ext/autosummary/generate.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 3b8495e72..6fb83f404 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 1.0.8 (Sep 23, 2011) ============================ +* #627: Fix tracebacks for AttributeErrors in autosummary generation. + * Fix the ``abbr`` role when the abbreviation has newlines in it. * #727: Fix the links to search results with custom object types. diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index b5ff3f4ca..86be0e53a 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -29,6 +29,7 @@ from jinja2.sandbox import SandboxedEnvironment from sphinx.ext.autosummary import import_by_name, get_documenter from sphinx.jinja2glue import BuiltinTemplateLoader from sphinx.util.osutil import ensuredir +from sphinx.util.inspect import safe_getattr def main(argv=sys.argv): usage = """%prog [OPTIONS] SOURCEFILE ...""" @@ -135,10 +136,14 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst', template = template_env.get_template('autosummary/base.rst') def get_members(obj, typ, include_public=[]): - items = [ - name for name in dir(obj) - if get_documenter(getattr(obj, name), obj).objtype == typ - ] + items = [] + for name in dir(obj): + try: + documenter = get_documenter(safe_getattr(obj, name), obj) + except AttributeError: + continue + if documenter.objtype == typ: + items.append(name) public = [x for x in items if x in include_public or not x.startswith('_')] return public, items