There already was a workaround for this for framework builds on OSX,
this changeset enables the same workaround for shared libraries.
Closes #
1602133
- Issue #13521: dict.setdefault() now does only one lookup for the given key,
making it "atomic" for many purposes. Patch by Filip GruszczyĆski.
+- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
+ now fills the ``os.environ`` variable correctly.
+
- Issue #14471: Fix a possible buffer overrun in the winreg module.
Library
#endif /* MS_WINDOWS */
/* Return a dictionary corresponding to the POSIX environment table */
-#ifdef WITH_NEXT_FRAMEWORK
+#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
/* On Darwin/MacOSX a shared library or framework has no access to
-** environ directly, we must obtain it with _NSGetEnviron().
+** environ directly, we must obtain it with _NSGetEnviron(). See also
+** man environ(7).
*/
#include <crt_externs.h>
static char **environ;
d = PyDict_New();
if (d == NULL)
return NULL;
-#ifdef WITH_NEXT_FRAMEWORK
+#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
if (environ == NULL)
environ = *_NSGetEnviron();
#endif