This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients bethard, ncoghlan, tebeka
Date 2014-08-21.14:04:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408629893.54.0.995437872373.issue22240@psf.upfronthosting.co.za>
In-reply-to
Content
I suspect resolving this will actually need special casing on the argparse side - __main__.__spec__ will have the original details for __main__ when executed via -m of zipfile/directory execution.

Things to check for:

* "__main__.__spec__ is not None" indicates a "-m" invocation
* __main__.__spec__.name will give you the module name that was executed
* if it is exactly "__main__" then this is likely zipfile or directory execution, and sys.argv[0] will still give the correct name
* if it ends with a ".__main__", it is likely package execution, and the last segment should be dropped
* otherwise, it is normal module execution

In the latter two cases, sys.executable can be used to figure out what to put before the "-m" (we don't expose the raw C level argv to Python, although there is an open RFE to do so somewhere on the tracker).
History
Date User Action Args
2014-08-21 14:04:53ncoghlansetrecipients: + ncoghlan, tebeka, bethard
2014-08-21 14:04:53ncoghlansetmessageid: <1408629893.54.0.995437872373.issue22240@psf.upfronthosting.co.za>
2014-08-21 14:04:53ncoghlanlinkissue22240 messages
2014-08-21 14:04:52ncoghlancreate