Skip to content

Commit b919795

Browse files
authored
bpo-32030: Fix calculate_path() on macOS (#4526)
1 parent b98f171 commit b919795

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Modules/getpath.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,15 @@ calculate_reduce_exec_prefix(PyCalculatePath *calculate, PyPathConfig *config)
589589
static void
590590
calculate_progpath(PyCalculatePath *calculate, PyPathConfig *config)
591591
{
592+
#ifdef __APPLE__
593+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
594+
uint32_t nsexeclength = MAXPATHLEN;
595+
#else
596+
unsigned long nsexeclength = MAXPATHLEN;
597+
#endif
598+
char execpath[MAXPATHLEN+1];
599+
#endif
600+
592601
/* If there is no slash in the argv0 path, then we have to
593602
* assume python is on the user's $PATH, since there's no
594603
* other way to find a directory to start the search from. If
@@ -597,15 +606,7 @@ calculate_progpath(PyCalculatePath *calculate, PyPathConfig *config)
597606
if (wcschr(calculate->prog, SEP)) {
598607
wcsncpy(config->progpath, calculate->prog, MAXPATHLEN);
599608
}
600-
601609
#ifdef __APPLE__
602-
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
603-
uint32_t nsexeclength = MAXPATHLEN;
604-
#else
605-
unsigned long nsexeclength = MAXPATHLEN;
606-
#endif
607-
char execpath[MAXPATHLEN+1];
608-
609610
/* On Mac OS X, if a script uses an interpreter of the form
610611
* "#!/opt/python2.3/bin/python", the kernel only passes "python"
611612
* as argv[0], which falls through to the $PATH search below.

0 commit comments

Comments
 (0)