[New-bugs-announce] [issue26388] Disabling changing sys.argv[0] with runpy.run_module(...alter_sys=True)

Mike Kaplinskiy report at bugs.python.org
Thu Feb 18 17:37:01 EST 2016


New submission from Mike Kaplinskiy:

For the purposes of pex (https://github.com/pantsbuild/pex), it would be useful to allow calling run_module without sys.argv[0] changing. In general, this behavior is useful if the script intends to re-exec itself (so it needs to know the original arguments that it was started with).

To make run_module more useful in general, I propose adding a `argv` parameter that has the following semantics:
 - (default) If set to a special value runpy.INHERIT (similar to subprocess.STDOUT), produces the current behavior of just changing sys.argv[0].
 - If set to None, does not touch sys.argv at all.
 - If set to an iterable, executes `sys.argv = [module.__file__] + list(argv)`, and properly reverts it once the module is done executing.

----------
components: Library (Lib)
messages: 260483
nosy: Mike Kaplinskiy
priority: normal
severity: normal
status: open
title: Disabling changing sys.argv[0] with runpy.run_module(...alter_sys=True)
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26388>
_______________________________________


More information about the New-bugs-announce mailing list