Message164998
When testing Eutaxia on PyPy (1.9) I discovered a discrepancy in the path_hooks import hook implementation. In CPython (2.7), if the find_module() method raises ImportError (as imp.find_module() does when it does not find a module in the given path), will cause the search to continue, whereas PyPy would propagate the ImportError.
PyPy has now been changed to behave like CPython.
The documentation is not entirely clear, but it does not explicitly document the import hook mechanism as eating an ImportError in find_module(). It should probably be made explicit, which ever way it should be. It is not obvious what is the correct behaviour, given the implicit relative imports, where the ImportError simply means that the import hook cannot find the module.
Quick testing on CPython 3.3 indicates that it behaves like PyPy did, but as it doesn't do implicit relative imports my test case didn't work as it was. For 3.3, without implicit relative imports, propagating the ImportError feels like the correct behaviour.
The attached demonstration needs a file /tmp/test/foo.py that does a top-level import, e.g. "import errno" to demonstrate the discrepancy. |
|
Date |
User |
Action |
Args |
2012-07-08 10:38:20 | iko | set | recipients:
+ iko, docs@python |
2012-07-08 10:38:20 | iko | set | messageid: <1341743900.84.0.0628684352519.issue15292@psf.upfronthosting.co.za> |
2012-07-08 10:38:20 | iko | link | issue15292 messages |
2012-07-08 10:38:19 | iko | create | |
|