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 <>
Good points, Nick.  I was trying to limit touches on 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 to resolve it, but even better may be to move it to 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.
Date User Action Args
2014-01-03 06:31:15eric.snowsetrecipients: + eric.snow, brett.cannon, ncoghlan, Arfrever
2014-01-03 06:31:15eric.snowsetmessageid: <>
2014-01-03 06:31:15eric.snowlinkissue19944 messages
2014-01-03 06:31:13eric.snowcreate