(original) (raw)

changeset: 81729:864b9836dae6 branch: 2.7 parent: 81725:11a18263ceb7 user: Ronald Oussoren ronaldoussoren@mac.com date: Fri Jan 25 17:55:39 2013 +0100 files: Misc/NEWS Modules/posixmodule.c description: 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 diff -r 11a18263ceb7 -r 864b9836dae6 Misc/NEWS --- a/Misc/NEWS Fri Jan 25 15:32:31 2013 +0100 +++ b/Misc/NEWS Fri Jan 25 17:55:39 2013 +0100 @@ -181,6 +181,9 @@ - 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 #10538: When using the "s*" code with PyArg_ParseTuple() to fill a Py_buffer structure with data from an object supporting only the old PyBuffer interface, a reference to the source objects is now properly added diff -r 11a18263ceb7 -r 864b9836dae6 Modules/posixmodule.c --- a/Modules/posixmodule.c Fri Jan 25 15:32:31 2013 +0100 +++ b/Modules/posixmodule.c Fri Jan 25 17:55:39 2013 +0100 @@ -441,9 +441,10 @@ #endif /* 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 static char **environ; @@ -463,7 +464,7 @@ 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/ronaldoussoren@mac.com