Author brett.cannon
Recipients amaury.forgeotdarc, brett.cannon, chris.jerdonek, georg.brandl, jeffknupp, ncoghlan, r.david.murray
Date 2012-08-22.16:33:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345653214.23.0.727702490854.issue15316@psf.upfronthosting.co.za>
In-reply-to
Content
It has nothing to do with runpy and __main__.py and everything to do with rev 78619:0d52f125dd32 (which fixed issue #15715) which was done to ignore bogus names in fromlist. If you simply change the import line to "import foo.bar" then you get the expected result.

The options I see to solve this without invalidating issue #15715 is:

1) Parse the ImportError message to notice that it was a lookup failure and not some other ImportError (ewww)

2) Importlib has to tag every exception is raises because of a finder failure to know when an ImportError was triggered because the module wasn't found (less eww, but still brittle as it means only importlib or people aware of the flag will have the expected semantics)

3) Create a ModuleNotFoundError exception that subclasses ImportError and catch that (breaks doctests and introduces a new exception that people will need to be aware of, plus the question of whether it should just exist in importlib or be a builtin)

4) change importlib._bootstrap._handle_fromlist (and various other bits of importlib code) to call _find_module() and silently ignore when no finder is found as desired (probably need to add a flag to _find_and_load() to signal whether finder failure just returns None or raises ImportError)

While I prefer 3, I think it's a bit late in the release to try to introduce a new exception to begin separating the meaning of 16 different ``raise ImportError`` cases in importlib._bootstrap based on inheritance. My gut says 4 is the best solution given the timeframe. I should be able to get a patch in on Friday if that works for people.
History
Date User Action Args
2012-08-22 16:33:34brett.cannonsetrecipients: + brett.cannon, georg.brandl, amaury.forgeotdarc, ncoghlan, r.david.murray, chris.jerdonek, jeffknupp
2012-08-22 16:33:34brett.cannonsetmessageid: <1345653214.23.0.727702490854.issue15316@psf.upfronthosting.co.za>
2012-08-22 16:33:33brett.cannonlinkissue15316 messages
2012-08-22 16:33:33brett.cannoncreate