New submission from Michael Foord <mich...@voidspace.org.uk>:

When you execute "python -m package" the package is first imported with 
sys.argv[0] set to '-c' (and sys.modules['__main__'] exists but is empty. Then 
package.__main__.py is executed with the correct sys.argv[0].

This means module level code executed during the initial import that attempts 
to work out how the code is being executed can't use either 
sys.modules['__main__'] *or* sys.argv[0].

----------
assignee: ncoghlan
messages: 101531
nosy: michael.foord, ncoghlan
severity: normal
status: open
title: sys.argv[0] and python -m package
type: behavior
versions: Python 2.7, Python 3.2

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

Reply via email to