[Python-Dev] Status of Python 3.6 PEPs?
ncoghlan at gmail.com
Tue Jul 12 21:54:21 EDT 2016
On 12 July 2016 at 19:26, Victor Stinner <victor.stinner at gmail.com> wrote:
> "PEP 499 -- python -m foo should bind sys.modules['foo'] in addition
> to sys.modules['__main__']"
> => 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:
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.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev