[Python-checkins] r80580 - in python/trunk: Doc/using/cmdline.rst Misc/NEWS Modules/main.c

nick.coghlan python-checkins at python.org
Wed Apr 28 16:51:08 CEST 2010


Author: nick.coghlan
Date: Wed Apr 28 16:51:08 2010
New Revision: 80580

Log:
Issue 8202: when using the -m command line switch, sys.argv[0] is now '-m' instead of '-c' while searching for the module to be executed

Modified:
   python/trunk/Doc/using/cmdline.rst
   python/trunk/Misc/NEWS
   python/trunk/Modules/main.c

Modified: python/trunk/Doc/using/cmdline.rst
==============================================================================
--- python/trunk/Doc/using/cmdline.rst	(original)
+++ python/trunk/Doc/using/cmdline.rst	Wed Apr 28 16:51:08 2010
@@ -95,8 +95,9 @@
       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::

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Apr 28 16:51:08 2010
@@ -12,6 +12,10 @@
 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

Modified: python/trunk/Modules/main.c
==============================================================================
--- python/trunk/Modules/main.c	(original)
+++ python/trunk/Modules/main.c	Wed Apr 28 16:51:08 2010
@@ -519,10 +519,10 @@
 	}
 
 	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);


More information about the Python-checkins mailing list