diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2010-08-17 13:06:11 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2010-08-17 13:06:11 (GMT) |
commit | d26c18adccf02321592cd58a2dadb0ab68af6906 (patch) | |
tree | 0429b57ab0d5cc0b36ca68af24f382c888cbcf9c /Python | |
parent | 46e63805638e0fac20aeae837e1f93b4a675446a (diff) | |
download | cpython-d26c18adccf02321592cd58a2dadb0ab68af6906.zip cpython-d26c18adccf02321592cd58a2dadb0ab68af6906.tar.gz cpython-d26c18adccf02321592cd58a2dadb0ab68af6906.tar.bz2 |
Issue #8202: Set sys.argv[0] to -m rather than -c while searching for the module to execute. Also updates all the cmd_line_script tests to validate the setting of sys.path[0] and the current working directory
Diffstat (limited to 'Python')
-rw-r--r-- | Python/sysmodule.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 7bf2c4c..013f5f1 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1723,6 +1723,10 @@ _wrealpath(const wchar_t *path, wchar_t *resolved_path) } #endif +#define _HAVE_SCRIPT_ARGUMENT(argc, argv) \ + (argc > 0 && argv0 != NULL && \ + wcscmp(argv0, L"-c") != 0 && wcscmp(argv0, L"-m") != 0) + void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) { @@ -1747,7 +1751,7 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) wchar_t link[MAXPATHLEN+1]; wchar_t argv0copy[2*MAXPATHLEN+1]; int nr = 0; - if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) + if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) nr = _Py_wreadlink(argv0, link, MAXPATHLEN); if (nr > 0) { /* It's a symlink */ @@ -1772,7 +1776,7 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) } #endif /* HAVE_READLINK */ #if SEP == '\\' /* Special case for MS filename syntax */ - if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) { + if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) { wchar_t *q; #if defined(MS_WINDOWS) && !defined(MS_WINCE) /* This code here replaces the first element in argv with the full @@ -1798,7 +1802,7 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) } } #else /* All other filename syntaxes */ - if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) { + if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) { #if defined(HAVE_REALPATH) if (_wrealpath(argv0, fullpath)) { argv0 = fullpath; |