Nick Coghlan added the comment: 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). ---------- nosy: +bethard _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22240> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com