Issue #1602133: 'environ' is not really available with shared libraries on OSX

There already was a workaround for this for framework builds on OSX,
this changeset enables the same workaround for shared libraries.

Closes #1602133
This commit is contained in:
Ronald Oussoren 2013-01-25 17:57:13 +01:00
parent 7981f20293
commit 697e56d0f5
2 changed files with 7 additions and 3 deletions

View File

@ -197,6 +197,9 @@ Core and Builtins
- Issue #13521: dict.setdefault() now does only one lookup for the given key, - Issue #13521: dict.setdefault() now does only one lookup for the given key,
making it "atomic" for many purposes. Patch by Filip Gruszczyński. 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. - Issue #14471: Fix a possible buffer overrun in the winreg module.
Library Library

View File

@ -501,9 +501,10 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
/* Return a dictionary corresponding to the POSIX environment table */ /* 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 /* 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> #include <crt_externs.h>
static char **environ; static char **environ;
@ -528,7 +529,7 @@ convertenviron(void)
d = PyDict_New(); d = PyDict_New();
if (d == NULL) if (d == NULL)
return NULL; return NULL;
#ifdef WITH_NEXT_FRAMEWORK #if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
if (environ == NULL) if (environ == NULL)
environ = *_NSGetEnviron(); environ = *_NSGetEnviron();
#endif #endif