This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: imp.find_module() -- be explicity that 'path' must be a list
Type: Stage:
Components: Documentation Versions: Python 3.0, Python 2.4, Python 3.1, Python 3.2, Python 2.7, Python 2.6, Python 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jordanb
Priority: normal Keywords:

Created on 2009-07-09 15:07 by jordanb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg90333 - (view) Author: Jordan Bettis (jordanb) Date: 2009-07-09 15:07
Hi. I just spent a while fighting with imp.find_module because I was
trying to pass the path as a string, rather than a string embedded in a

result = find_module('mod', '/path')

rather than

result = find_module('mod', ['/path'])

The issue is compounded by an incredibly unhelpful error message:

ImportError: No frozen submodule named /path.mod

Now the documentation *does* say that path should be a list, if you read
it carefully, so perhaps it was just my reading comprehension. But doing
a google search I found a discussion from 2006 along the same lines:

So I thought it might be good to clarify that a string will not work.
Perhaps the wording could be changed to something like this:

   Try to find the module *name* on the search path *path*.  The
   *path* argument is a list of directory names. Each directory is
   searched for files with any of the suffixes returned
   by :func:`get_suffixes` above.  Invalid names in the list are
   silently ignored (but all list items must be strings).  If
   *path* is omitted or ``None``, the list of directory names
   given by ``sys.path`` is searched, but first it searches a few
   special places: it tries to find a built-in module with the
   given name (:const:`C_BUILTIN`), then a frozen
   module (:const:`PY_FROZEN`), and on some systems some other
   places are looked in as well (on Windows, it looks in the
   registry which may point to a specific file).

I think what is confusing is the conditional about the type of 'path',
The possibilities are 'list' or 'not present' (or None) but when I read
it I think I saw the 'not present' option as being implicit, and the
conditional implying that it could be a string or a list of strings.
From the discussion above it seems like the other person had the same
trouble, so removing the conditional should be enough to make it clear
that path *must* be a list if it exists.
msg90410 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 10:18
I reworded the paragraph a bit in r73939.
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50697
2009-07-11 10:18:30georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90410
2009-07-09 15:07:23jordanbcreate