Author ncoghlan
Recipients brett.cannon, eric.snow, martin.panter, ncoghlan, wolma
Date 2016-07-14.03:30:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1468467019.3.0.470043570214.issue27487@psf.upfronthosting.co.za>
In-reply-to
Content
In http://bugs.python.org/issue27487#msg270300, Wolfgang noted: "In fact, for my own case I have now refactored things a bit so I can avoid the import from __init__.py."

So I take that to mean that Wolfgang's particular project is now compatible with the new 3.5.2 behaviour, or at least will be as of its next release (Wolfgang, please correct me if I've misinterpreted your comment).

The "double import" implications involved here aren't entirely clearcut though, as even in 3.5.2 if a leaf module invoked via "-m" is a normal module, importing it from the parent package's __init__ module (or any other part of the startup process, like a .pth file) will still lead to it being executed twice.

What's changed is that if the leaf module replaces itself in sys.modules with an object that doesn't have a __spec__ attribute, then executing it with -m will fail, rather than re-running the module level code as __main__ the way it will for a normal module.
History
Date User Action Args
2016-07-14 03:30:19ncoghlansetrecipients: + ncoghlan, brett.cannon, eric.snow, martin.panter, wolma
2016-07-14 03:30:19ncoghlansetmessageid: <1468467019.3.0.470043570214.issue27487@psf.upfronthosting.co.za>
2016-07-14 03:30:19ncoghlanlinkissue27487 messages
2016-07-14 03:30:18ncoghlancreate