Nick Coghlan added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to