Skip to content

Commit

Permalink
Issue #1602133: 'environ' is not really available with shared librari…
Browse files Browse the repository at this point in the history
…es 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
  • Loading branch information
ronaldoussoren committed Jan 25, 2013
2 parents 96a9f89 + 697e56d commit 1c90eed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ Core and Builtins
Library
-------

- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
now fills the ``os.environ`` variable correctly.

- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
interface and support all mandatory methods and properties.

Expand Down
7 changes: 4 additions & 3 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,10 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
#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;
Expand All @@ -982,7 +983,7 @@ convertenviron(void)
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
Expand Down

0 comments on commit 1c90eed

Please sign in to comment.