[docs] [issue15292] import hook behavior documentation improvement
report at bugs.python.org
Sun Jul 8 13:33:22 CEST 2012
Nick Coghlan <ncoghlan at gmail.com> added the comment:
The PyPy and 3.3 behaviour are actually correct according to the spec, but it's *really* unclear in PEP 302.
sys.meta_path accepts finder objects. These are explicitly documented as returning "None" from find_module() to indicate "try the next one" and raising exceptions solely to report problems.
However, for reasons that are unknown to me, sys.path_hooks entries (which occupy most of the section on registering hooks) use a different protocol to indicate "try the next one": raising ImportError.
Since meta_path and path_hooks are described in the same section, and the meta_path description just says "add finder objects", it's understandable that implementors take the path_hooks protocol description as applying to finders in general :(
I would chalk the 2.x (and likely 3.x for x < 3) behaviour up to the only partial implementation of PEP 302 in CPython (until Brett's success in bootstrapping importlib for 3.3).
Python tracker <report at bugs.python.org>
More information about the docs