On 12 July 2016 at 19:26, Victor Stinner <victor.stin...@gmail.com> wrote:
> "PEP 499 -- python -m foo should bind sys.modules['foo'] in addition
> to sys.modules['__main__']"
> https://www.python.org/dev/peps/pep-0499/
> => draft

I'm a little wary of this one, as we just received a bug report
regarding some subtleties of the 3.5.2 change that separated the
"import the parent module" step from the "execute the requested main
module" step when using the -m switch with a submodule:
http://bugs.python.org/issue27487

The problem there relates to some odd behaviour that can arise when
importing the parent module implicitly imports the submodule that has
been requested to be run as __main__. While PEP 499 would eliminate
the dual import problem when the import happens *after* __main__
starts execution, it wouldn't prevent it when the import happens
*first* (as in the case of it happening as a side-effect of importing
the parent module), making the consequences even more surprising and
harder to debug.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to