Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20190e2

Browse files
Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.3)
There already was a workaround for this for framework builds on OSX, this changeset enables the same workaround for shared libraries. Closes #1602133
2 parents 454ea92 + 1c90eed commit 20190e2

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ Core and Builtins
218218
Library
219219
-------
220220

221+
- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
222+
now fills the ``os.environ`` variable correctly.
223+
221224
- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
222225
interface and support all mandatory methods and properties.
223226

Modules/posixmodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,10 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
924924
#endif /* MS_WINDOWS */
925925

926926
/* Return a dictionary corresponding to the POSIX environment table */
927-
#ifdef WITH_NEXT_FRAMEWORK
927+
#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
928928
/* On Darwin/MacOSX a shared library or framework has no access to
929-
** environ directly, we must obtain it with _NSGetEnviron().
929+
** environ directly, we must obtain it with _NSGetEnviron(). See also
930+
** man environ(7).
930931
*/
931932
#include <crt_externs.h>
932933
static char **environ;
@@ -947,7 +948,7 @@ convertenviron(void)
947948
d = PyDict_New();
948949
if (d == NULL)
949950
return NULL;
950-
#ifdef WITH_NEXT_FRAMEWORK
951+
#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
951952
if (environ == NULL)
952953
environ = *_NSGetEnviron();
953954
#endif

0 commit comments

Comments
 (0)