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.

Author iko
Recipients docs@python, iko
Date 2012-07-08.10:38:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341743900.84.0.0628684352519.issue15292@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-07-08 10:38:20ikosetrecipients: + iko, docs@python
2012-07-08 10:38:20ikosetmessageid: <1341743900.84.0.0628684352519.issue15292@psf.upfronthosting.co.za>
2012-07-08 10:38:20ikolinkissue15292 messages
2012-07-08 10:38:19ikocreate