You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subprocess.Popen can pass incomplete environment when posix_spawn is used #113119
Subprocess created with posix_spawn can have different environment when compared to a process created with stardard fork/exec.
The reason is that posix_spawn uses os.environ (when no env was given), which is not affected by os.putenv and os.unsetenv. This is different from execv, which uses process environment (available through environ).
This can be easily reproduced with test_putenv_unsetenv modified to call subprocess.run with close_fds=False (which makes it use the posix_spawn call):
reopened due to @ned-deily reporting on a parallel issue #113117 about this change:
This breaks macOS framework builds such as those used by the python.org installer:
$ ./configure --enable-framework && make -j
[...]
./Modules/posixmodule.c:7170:19: error: use of undeclared identifier 'environ'
envlist = environ;
^
./Modules/posixmodule.c:7238:31: error: use of undeclared identifier 'environ'
if (envlist && envlist != environ) {
^
Note the comments elsewhere in posixmodule.c such as at line 1582:
#elif defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
/* environ is not accessible as an extern in a shared object on OSX; use
_NSGetEnviron to resolve it. The value changes if you add environment
variables between calls to Py_Initialize, so don't cache the value. */
e = *_NSGetEnviron();
Activity
gh-113119 fix environment handling in subprocess.Popen when posix_spa…
gpshead commentedon Dec 19, 2023
reopened due to @ned-deily reporting on a parallel issue #113117 about this change:
This breaks macOS framework builds such as those used by the python.org installer:
Note the comments elsewhere in posixmodule.c such as at line 1582:
gh-113119: Fix the macOS framework installer build (#113268)
kulikjak commentedon Dec 19, 2023
Sorry for that, and thank you for the fix. Since CI was green, I didn't look into it much more and missed that.
pythongh-113119: Fix the macOS framework installer build (python#113268)
pythongh-113119 fix environment handling in subprocess.Popen when pos…
pythongh-113119: Fix the macOS framework installer build (python#113268)
pythongh-113119 fix environment handling in subprocess.Popen when pos…
pythongh-113119: Fix the macOS framework installer build (python#113268)