diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6929,11 +6929,15 @@ static PyObject * posix_unsetenv(PyObject *self, PyObject *args) { char *s1; + int rc; if (!PyArg_ParseTuple(args, "s:unsetenv", &s1)) return NULL; - unsetenv(s1); + rc = unsetenv(s1); + fprintf(stderr, "unsetenv returned %d\n", rc); + if (rc != 0) + perror("error message"); /* Remove the key from posix_putenv_garbage; * this will cause it to be collected. This has to @@ -9243,6 +9247,9 @@ INITFUNC(void) #ifdef HAVE_PUTENV if (posix_putenv_garbage == NULL) posix_putenv_garbage = PyDict_New(); + Py_XINCREF(posix_putenv_garbage); + if (posix_putenv_garbage == NULL || PyModule_AddObject(m, "posix_putenv_garbage", posix_putenv_garbage) != 0) + return NULL; #endif if (!initialized) {