Add a sentence clarifying that once a path_hooks importer has

been found for a sys.path entry, the builtin import machinery will not
handle that entry any longer.
This commit is contained in:
Georg Brandl 2006-08-11 07:11:14 +00:00
parent 0cae307351
commit 790d967970
1 changed files with 10 additions and 7 deletions

View File

@ -311,13 +311,16 @@ Specification part 2: Registering Hooks
sequence to determine if they can handle a given path item. The sequence to determine if they can handle a given path item. The
callable is called with one argument, the path item. The callable callable is called with one argument, the path item. The callable
must raise ImportError if it is unable to handle the path item, and must raise ImportError if it is unable to handle the path item, and
return an importer object if it can handle the path item. The return an importer object if it can handle the path item. Note
callable is typically the class of the import hook, and hence the that if the callable returns an importer object for a specific
class __init__ method is called. (This is also the reason why it sys.path entry, the builtin import machinery will not be invoked
should raise ImportError: an __init__ method can't return anything. to handle that entry any longer, even if the importer object later
This would be possible with a __new__ method in a new style class, fails to find a specific module. The callable is typically the
but we don't want to require anything about how a hook is class of the import hook, and hence the class __init__ method is
implemented.) called. (This is also the reason why it should raise ImportError:
an __init__ method can't return anything. This would be possible
with a __new__ method in a new style class, but we don't want to
require anything about how a hook is implemented.)
The results of path hook checks are cached in The results of path hook checks are cached in
sys.path_importer_cache, which is a dictionary mapping path entries sys.path_importer_cache, which is a dictionary mapping path entries