Importing failure in autosummary module (when importing packages)

Vadim Fint avatarVadim Fint created an issue

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

And this sphinx doc code snippet:

.. autosummary::
   :toctree: gen

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('.')
            modname = '.'.join(name_parts[:-1])
            return getattr(sys.modules[modname], name_parts[-1])
        except (ImportError, IndexError, AttributeError):

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 (7)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.