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

Skip to content

Commit 1c90eed

Browse files
Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.2)
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 96a9f89 + 697e56d commit 1c90eed

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
@@ -150,6 +150,9 @@ Core and Builtins
150150
Library
151151
-------
152152

153+
- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
154+
now fills the ``os.environ`` variable correctly.
155+
153156
- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
154157
interface and support all mandatory methods and properties.
155158

Modules/posixmodule.c

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

957957
/* Return a dictionary corresponding to the POSIX environment table */
958-
#ifdef WITH_NEXT_FRAMEWORK
958+
#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
959959
/* On Darwin/MacOSX a shared library or framework has no access to
960-
** environ directly, we must obtain it with _NSGetEnviron().
960+
** environ directly, we must obtain it with _NSGetEnviron(). See also
961+
** man environ(7).
961962
*/
962963
#include <crt_externs.h>
963964
static char **environ;
@@ -982,7 +983,7 @@ convertenviron(void)
982983
d = PyDict_New();
983984
if (d == NULL)
984985
return NULL;
985-
#ifdef WITH_NEXT_FRAMEWORK
986+
#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
986987
if (environ == NULL)
987988
environ = *_NSGetEnviron();
988989
#endif

0 commit comments

Comments
 (0)