summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2011-11-27 13:01:35 +0100
committerCharles-François Natali <neologix@free.fr>2011-11-27 13:01:35 +0100
commit93a1175bacd415061ac61107e58f24fe9ced82ff (patch)
tree5737c3ed9555248fad1a25d2cdc3d581af6af3c8
parent710671a72277b0196611cdfbb11b3cd0c49a93de (diff)
downloadcpython-git-93a1175bacd415061ac61107e58f24fe9ced82ff.tar.gz
Issue #13415: Test in configure if unsetenv() has a return value or not.
-rw-r--r--Modules/posixmodule.c6
-rwxr-xr-xconfigure28
-rw-r--r--configure.in9
-rw-r--r--pyconfig.h.in3
4 files changed, 46 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 6555f1f511..f249e1e8cb 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7044,14 +7044,20 @@ static PyObject *
posix_unsetenv(PyObject *self, PyObject *args)
{
char *s1;
+#ifndef HAVE_BROKEN_UNSETENV
int err;
+#endif
if (!PyArg_ParseTuple(args, "s:unsetenv", &s1))
return NULL;
+#ifdef HAVE_BROKEN_UNSETENV
+ unsetenv(s1);
+#else
err = unsetenv(s1);
if (err)
return posix_error();
+#endif
/* Remove the key from posix_putenv_garbage;
* this will cause it to be collected. This has to
diff --git a/configure b/configure
index 7d6423ad2b..72a758e1cf 100755
--- a/configure
+++ b/configure
@@ -9924,6 +9924,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.
diff --git a/configure.in b/configure.in
index 9d7bfa6f8f..454e4681da 100644
--- a/configure.in
+++ b/configure.in
@@ -2831,6 +2831,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)
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 9d340f6e0a..b9da3d935c 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -97,6 +97,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