Author eric.snow
Recipients Arfrever, brett.cannon, eric.snow, ncoghlan
Date 2014-01-03.06:31:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388730675.3.0.35568723906.issue19944@psf.upfronthosting.co.za>
In-reply-to
Content
Good points, Nick.  I was trying to limit touches on _bootstrap.py for 3.4, but that "simple" patch is mostly just a hacky band-aid.  Here's a patch that hopefully stands on its own and still limits touches.  (The patch is the bare-bones changes only.)

There are 2 things in particular with this patch that I'd like to be sure others are comfortable with:

* an import statement (for resolve_name) inside find_spec()
* the use of builtins.__import__() instead of importlib.import_module()

Regarding the "nested" import, I didn't want to import the submodule at the top level due to possible future circular imports (there aren't any now with importlib.util, but still...).  At the same time, to me using something out of a submodule in the parent module in this way is a bit of a bad code smell.  I'd be more inclined to move the resolve_name() implementation into _bootstrap.py to resolve it, but even better may be to move it to __init__.py as a private name and then import it into importlib.util.  As it stands, the patch simply uses the "nested" import.

As to using builtins.__import__() when importing the parent module, that seems like it would result in less surprising results in the (uncommon) case that someone is using a custom __import__() that would yield a different result than importlib.import_module().  In the case of find_spec() that makes more sense to me.
History
Date User Action Args
2014-01-03 06:31:15eric.snowsetrecipients: + eric.snow, brett.cannon, ncoghlan, Arfrever
2014-01-03 06:31:15eric.snowsetmessageid: <1388730675.3.0.35568723906.issue19944@psf.upfronthosting.co.za>
2014-01-03 06:31:15eric.snowlinkissue19944 messages
2014-01-03 06:31:13eric.snowcreate