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 ncoghlan
Recipients Arfrever, brett.cannon, chris.jerdonek, eric.araujo, eric.smith, gennad, ncoghlan
Date 2012-07-16.13:53:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342446824.19.0.825979597694.issue14787@psf.upfronthosting.co.za>
In-reply-to
Content
Right, this is a separate bug in pkgutil. Specifically, when it goes to import a package in order to check it for submodules, it invokes the global import system via __import__() rather than constraining the import to the path argument supplied to walk_packages.

This means that it will only find it if the path being walked is already on sys.path. In the case of your example, it isn't (it's on a subdirectory).

The reason my new tests didn't pick this up is that they're built on the test_runpy infrastructure, and one of the steps in that infrastructure is to add the new package path to sys.path so it can be imported.

This isn't an easy one to fix - you basically need something along the lines of a PEP 406 style import engine API in order to do the import without having potentially adverse effects on the state in the sys module.
History
Date User Action Args
2012-07-16 13:53:44ncoghlansetrecipients: + ncoghlan, brett.cannon, eric.smith, eric.araujo, Arfrever, chris.jerdonek, gennad
2012-07-16 13:53:44ncoghlansetmessageid: <1342446824.19.0.825979597694.issue14787@psf.upfronthosting.co.za>
2012-07-16 13:53:43ncoghlanlinkissue14787 messages
2012-07-16 13:53:43ncoghlancreate