diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5899,6 +5899,7 @@ Delete an environment variable."); static PyObject * posix_unsetenv(PyObject *self, PyObject *args) { + int rc; #ifdef MS_WINDOWS char *s1; @@ -5914,7 +5915,10 @@ posix_unsetenv(PyObject *self, PyObject s1 = PyBytes_AsString(os1); #endif - 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 @@ -8187,6 +8191,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) {