Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 68535) +++ Modules/posixmodule.c (working copy) @@ -5229,11 +5229,15 @@ 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 @@ -7394,6 +7398,9 @@ #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) {