Skip to content

Commit c895403

Browse files
authored
gh-113119: Fix the macOS framework installer build (#113268)
`--enable-framework` builds were failing. we apparently do not have good CI & buildbot coverage here.
1 parent 893c9cc commit c895403

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Modules/posixmodule.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ _Py_Sigset_Converter(PyObject *obj, void *addr)
15571557
** man environ(7).
15581558
*/
15591559
#include <crt_externs.h>
1560+
#define USE_DARWIN_NS_GET_ENVIRON 1
15601561
#elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
15611562
extern char **environ;
15621563
#endif /* !_MSC_VER */
@@ -1579,7 +1580,7 @@ convertenviron(void)
15791580
through main() instead of wmain(). */
15801581
(void)_wgetenv(L"");
15811582
e = _wenviron;
1582-
#elif defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
1583+
#elif defined(USE_DARWIN_NS_GET_ENVIRON)
15831584
/* environ is not accessible as an extern in a shared object on OSX; use
15841585
_NSGetEnviron to resolve it. The value changes if you add environment
15851586
variables between calls to Py_Initialize, so don't cache the value. */
@@ -7166,7 +7167,15 @@ py_posix_spawn(int use_posix_spawnp, PyObject *module, path_t *path, PyObject *a
71667167
goto exit;
71677168
}
71687169

7170+
#ifdef USE_DARWIN_NS_GET_ENVIRON
7171+
// There is no environ global in this situation.
7172+
char **environ = NULL;
7173+
#endif
7174+
71697175
if (env == Py_None) {
7176+
#ifdef USE_DARWIN_NS_GET_ENVIRON
7177+
environ = *_NSGetEnviron();
7178+
#endif
71707179
envlist = environ;
71717180
} else {
71727181
envlist = parse_envlist(env, &envc);

0 commit comments

Comments
 (0)