Issue #384 resolved

Importing failure in autosummary module (when importing packages)

Vadim Fint
created an issue

E.g. I have big package named 'ipi'.

And this sphinx doc code snippet:

{{{ .. autosummary:: :toctree: gen

ipi ipi.core }}}

Fails to import 'ipi', but successfully imports 'ipi.core'.

Fast digging into sphinx code shows following:

in sphinx.ext.autosummary.init "_import_by_name()" called with 'ipi' argument (coz I have no prefixes in my setup). Next, in "_import_by_name()" error occurs here:

{{{ (...) name_parts = name.split('.') try: modname = '.'.join(name_parts[:-1]) import(modname) return getattr(sys.modules[modname], name_parts[-1]) except (ImportError, IndexError, AttributeError): pass (...) }}}

name_parts will be ['ipi'], modname in try statement will be '' (blank). Importing blank module raises "ValueError", so it is not catched here.

Proper fixup should be not adding ValueError to catched exception list, but just make "modname.obj" check only if len(name_parts) > 1.

Occurs in 0.6.5 (gentoo bouild). But quick analyzing of latest sources shows that this code is the same for sphinx trunk as of now.

Comments (8)

  1. Log in to comment