diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-22 20:53:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-22 20:53:26 (GMT) |
commit | 0852c7dd52ac42e7843ddfef44571494e4c86070 (patch) | |
tree | e182849a42c1ef465528c6e19e74363b370f1ccb /Modules | |
parent | b73dd02ea744288831f71363a7467552c09875ea (diff) | |
download | cpython-0852c7dd52ac42e7843ddfef44571494e4c86070.zip cpython-0852c7dd52ac42e7843ddfef44571494e4c86070.tar.gz cpython-0852c7dd52ac42e7843ddfef44571494e4c86070.tar.bz2 |
bpo-39406: os.putenv() avoids putenv_dict on Windows (GH-18126)
Windows: _wputenv(env) copies the *env* string and doesn't require
the caller to manage the variable memory.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index e0eecfa..71b99fd 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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 @@ -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: |