Skip to content

Commit

Permalink
bpo-39406: os.putenv() avoids putenv_dict on Windows (GH-18126)
Browse files Browse the repository at this point in the history
Windows: _wputenv(env) copies the *env* string and doesn't require
the caller to manage the variable memory.
  • Loading branch information
vstinner authored Jan 22, 2020
1 parent b73dd02 commit 0852c7d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ dir_fd_converter(PyObject *o, void *p)
}
}

#ifdef HAVE_PUTENV
/* Windows: _wputenv(env) copies the *env* string and doesn't require the
caller to manage the variable memory. */
#if defined(HAVE_PUTENV) && !defined(MS_WINDOWS)
# define PY_PUTENV_DICT
#endif

Expand Down Expand Up @@ -10130,8 +10132,10 @@ os_putenv_impl(PyObject *module, PyObject *name, PyObject *value)
posix_error();
goto error;
}
/* _wputenv(env) copies the *env* string and doesn't require the caller
to manage the variable memory. */
Py_DECREF(unicode);

posix_putenv_dict_setitem(name, unicode);
Py_RETURN_NONE;

error:
Expand Down

0 comments on commit 0852c7d

Please sign in to comment.