diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-23 19:02:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 19:02:04 +0100 |
commit | b9197959c186f9061bd74d0adc20e96556426db4 (patch) | |
tree | f0bf4686455e21c9f69ea94e8ff1fda6fd52b030 /Modules/getpath.c | |
parent | b98f1715a35d2cbd1e9e45e1e7ae51a39e00dc4a (diff) | |
download | cpython-git-b9197959c186f9061bd74d0adc20e96556426db4.tar.gz |
bpo-32030: Fix calculate_path() on macOS (#4526)
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index d8125ae2ca..48bdd0f21d 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -589,6 +589,15 @@ calculate_reduce_exec_prefix(PyCalculatePath *calculate, PyPathConfig *config) static void calculate_progpath(PyCalculatePath *calculate, PyPathConfig *config) { +#ifdef __APPLE__ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + uint32_t nsexeclength = MAXPATHLEN; +#else + unsigned long nsexeclength = MAXPATHLEN; +#endif + char execpath[MAXPATHLEN+1]; +#endif + /* If there is no slash in the argv0 path, then we have to * assume python is on the user's $PATH, since there's no * other way to find a directory to start the search from. If @@ -597,15 +606,7 @@ calculate_progpath(PyCalculatePath *calculate, PyPathConfig *config) if (wcschr(calculate->prog, SEP)) { wcsncpy(config->progpath, calculate->prog, MAXPATHLEN); } - #ifdef __APPLE__ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - uint32_t nsexeclength = MAXPATHLEN; -#else - unsigned long nsexeclength = MAXPATHLEN; -#endif - char execpath[MAXPATHLEN+1]; - /* On Mac OS X, if a script uses an interpreter of the form * "#!/opt/python2.3/bin/python", the kernel only passes "python" * as argv[0], which falls through to the $PATH search below. |