]> granicus.if.org Git - python/commitdiff
Close #13415: Test in configure if unsetenv() has a return value or not.
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 24 Nov 2011 12:53:38 +0000 (13:53 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 24 Nov 2011 12:53:38 +0000 (13:53 +0100)
Patch written by Charles-François Natali.

Modules/posixmodule.c
configure
configure.in
pyconfig.h.in

index e42db5ba8d56720cbf2d06fc2a255ca7931e4b58..8ba2975a9daf36df2b018c6072d8e547616739ac 100644 (file)
@@ -7841,19 +7841,24 @@ static PyObject *
 posix_unsetenv(PyObject *self, PyObject *args)
 {
     PyObject *name;
+#ifndef HAVE_BROKEN_UNSETENV
     int err;
+#endif
 
     if (!PyArg_ParseTuple(args, "O&:unsetenv",
 
                           PyUnicode_FSConverter, &name))
         return NULL;
 
-
+#ifdef HAVE_BROKEN_UNSETENV
+    unsetenv(PyBytes_AS_STRING(name));
+#else
     err = unsetenv(PyBytes_AS_STRING(name));
     if (err) {
         Py_DECREF(name);
         return posix_error();
     }
+#endif
 
     /* Remove the key from posix_putenv_garbage;
      * this will cause it to be collected.  This has to
index 596336ee96cd9f15c2d01ba65f67ab315edfb1c5..112c20aa6f259e2de4c543208aa9265678bdf634 100755 (executable)
--- a/configure
+++ b/configure
@@ -9812,6 +9812,34 @@ $as_echo "no" >&6; }
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken unsetenv" >&5
+$as_echo_n "checking for broken unsetenv... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stdlib.h>
+
+int
+main ()
+{
+int res = unsetenv("DUMMY")
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+
+$as_echo "#define HAVE_BROKEN_UNSETENV 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 for ac_prog in true
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
index 532ec921842adcfde21aef36dba7a31d351cfa7f..b41e7508350265a8ff7c0cf34fb5ca4905609324 100644 (file)
@@ -2688,6 +2688,15 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
   [AC_MSG_RESULT(no)
 ])
 
+AC_MSG_CHECKING(for broken unsetenv)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <stdlib.h>
+]], [[int res = unsetenv("DUMMY")]])],
+  [AC_MSG_RESULT(no)],
+  [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
+   AC_MSG_RESULT(yes)
+])
+
 dnl check for true
 AC_CHECK_PROGS(TRUE, true, /bin/true)
 
index 2d1fd48fe3c9382e75f4f6dd0d5e7985596f28a2..efe732f13811a20f3716bba95dc7bf45cb9a93de 100644 (file)
@@ -95,6 +95,9 @@
 /* define to 1 if your sem_getvalue is broken. */
 #undef HAVE_BROKEN_SEM_GETVALUE
 
+/* Define if `unsetenv` does not return an int. */
+#undef HAVE_BROKEN_UNSETENV
+
 /* Define this if you have the type _Bool. */
 #undef HAVE_C99_BOOL