1. mirror
  2. cpython

Commits

Nick Coghlan  committed 8f137a5

Revert r80580 due to some unintended side effects. See issue #8202 for details.

  • Participants
  • Parent commits b9ecdce
  • Branches legacy-trunk

Comments (0)

Files changed (3)

File Doc/using/cmdline.rst

View file
  • Ignore whitespace
       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 (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`.
+   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`.
 
    Many standard library modules contain code that is invoked on their execution
    as a script.  An example is the :mod:`timeit` module::

File Misc/NEWS

View file
  • Ignore whitespace
 Core and Builtins
 -----------------
 
+- Issue #8202: Previous change to ``sys.argv[0]`` handling for -m command line
+  option reverted due to unintended side effects on handling of ``sys.path``.
+  See tracker issue for details.
+
 - Issue #8941: decoding big endian UTF-32 data in UCS-2 builds could crash
   the interpreter with characters outside the Basic Multilingual Plane
   (higher than 0x10000).

File Modules/main.c

View file
  • Ignore whitespace
     }
 
     if (module != NULL) {
-        /* Backup _PyOS_optind and force sys.argv[0] = '-m'
-           so that PySys_SetArgv correctly sets sys.path[0] to ''*/
+        /* Backup _PyOS_optind and force sys.argv[0] = '-c'
+           so that PySys_SetArgv correctly sets sys.path[0] to ''
+           rather than looking for a file called "-m". See
+           tracker issue #8202 for details. */
         _PyOS_optind--;
-        argv[_PyOS_optind] = "-m";
+        argv[_PyOS_optind] = "-c";
     }
 
     PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind);