]> granicus.if.org Git - python/commitdiff
Issue #1602133: 'environ' is not really available with shared libraries on OSX
authorRonald Oussoren <ronaldoussoren@mac.com>
Fri, 25 Jan 2013 16:55:39 +0000 (17:55 +0100)
committerRonald Oussoren <ronaldoussoren@mac.com>
Fri, 25 Jan 2013 16:55:39 +0000 (17:55 +0100)
There already was a workaround for this for framework builds on OSX,
this changeset enables the same workaround for shared libraries.

Closes #1602133

Misc/NEWS
Modules/posixmodule.c

index 1f6875de42329cf9d7c1a2b1f8039677ed21c0da..3a4a6cc179372a0792b1e35ec5aafb0cb2f1790f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -181,6 +181,9 @@ Core and Builtins
 - 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
index 21a6739d21762376be277f5b62ed90699ab6f15a..d2742a0ee15dc5c68e9726e85d377d6755217b3f 100644 (file)
@@ -441,9 +441,10 @@ _PyVerify_fd_dup2(int fd1, int fd2)
 #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 <crt_externs.h>
 static char **environ;
@@ -463,7 +464,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