Nick Coghlan added the comment:

I think this is just a straight-up interaction bug where we never accounted for 
the combination of -I with directory and zipfile execution back when -I was 
added.

>From a bug fix perspective, I think the right thing to do in all affected 
>versions would be to add a check to RunMainFromImporter such that it does an 
>insert rather than a set when -I is used.

For 3.7+, it may make sense to change the signature of 
runpy._run_module_as_main to accept the path entry as Steve suggests, as that 
could also resolve the quirk where we'll run a __main__ module from *anywhere* 
on sys.path, rather than only from the given path entry.

The core of the current approach was implemented back in the 2.6 time frame, 
and then tweaked a bit in 2.7, and hence predates all the niceties offered by 
the importlib API.

However, the latter change would be a separate RFE rather than a bug fix.

----------

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

Reply via email to