diff options
-rw-r--r-- | Doc/using/cmdline.rst | 5 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Modules/main.c | 4 |
3 files changed, 9 insertions, 4 deletions
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index a444228..0199f9f 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -95,8 +95,9 @@ source. file is not available. If this option is given, the first element of :data:`sys.argv` will be the - full path to the module file. As with the :option:`-c` option, the current - directory will be added to the start of :data:`sys.path`. + full path to the module file (while the module file is being located, the + first element will be set to ``"-m"``). As with the :option:`-c` option, + the current directory will be added to the start of :data:`sys.path`. Many standard library modules contain code that is invoked on their execution as a script. An example is the :mod:`timeit` module:: @@ -12,6 +12,10 @@ What's New in Python 2.7 beta 2? Core and Builtins ----------------- +- Issue #8202: sys.argv[0] is now set to '-m' instead of '-c' when + searching for the module file to be executed with the -m command + line option + - Issue #7319: When -Q is used, do not silence DeprecationWarning. - Issue #7332: Remove the 16KB stack-based buffer in diff --git a/Modules/main.c b/Modules/main.c index 11ac97e..2f5dc57 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -519,10 +519,10 @@ Py_Main(int argc, char **argv) } if (module != NULL) { - /* Backup _PyOS_optind and force sys.argv[0] = '-c' + /* Backup _PyOS_optind and force sys.argv[0] = '-m' so that PySys_SetArgv correctly sets sys.path[0] to ''*/ _PyOS_optind--; - argv[_PyOS_optind] = "-c"; + argv[_PyOS_optind] = "-m"; } PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind); |