Author ncoghlan
Recipients BreamoreBoy, eric.araujo, eric.snow, martin.panter, ncoghlan, python-dev, robagar, schlamar
Date 2015-12-04.06:38:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1449211113.64.0.20751446203.issue14285@psf.upfronthosting.co.za>
In-reply-to
Content
I'm wondering if there might be a simpler option: use rpartition() to strip off any trailing segment (whether that's "__main__" or not), and then always do a plain dynamic import of that package (if any). Something like the following at the start of _get_module_details():

    pkg_name, is_submodule, submodule = mod_name.rpartition(".")
    if is_submodule:
        __import__(pkg_name)

The key is that we *don't* want to be relying on the fact find_spec() will import parent packages implicitly.
History
Date User Action Args
2015-12-04 06:38:33ncoghlansetrecipients: + ncoghlan, eric.araujo, BreamoreBoy, python-dev, schlamar, eric.snow, martin.panter, robagar
2015-12-04 06:38:33ncoghlansetmessageid: <1449211113.64.0.20751446203.issue14285@psf.upfronthosting.co.za>
2015-12-04 06:38:33ncoghlanlinkissue14285 messages
2015-12-04 06:38:33ncoghlancreate