summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-01-22 20:11:17 (GMT)
committerGitHub <noreply@github.com>2020-01-22 20:11:17 (GMT)
commitb73dd02ea744288831f71363a7467552c09875ea (patch)
tree7fb902e5dc770d760f7a67e4c8ed469102d43380 /Modules/posixmodule.c
parentbeea26b57e8c80f1eff0f967a0f9d083a7dc3d66 (diff)
downloadcpython-b73dd02ea744288831f71363a7467552c09875ea.zip
cpython-b73dd02ea744288831f71363a7467552c09875ea.tar.gz
cpython-b73dd02ea744288831f71363a7467552c09875ea.tar.bz2
Revert "bpo-39413: Implement os.unsetenv() on Windows (GH-18104)" (GH-18124)
This reverts commit 56cd3710a1ea3ba872d345ea1bebc86ed08bc8b8.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c46
1 files changed, 1 insertions, 45 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5a0c8a3..e0eecfa 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -10180,51 +10180,7 @@ os_putenv_impl(PyObject *module, PyObject *name, PyObject *value)
#endif /* HAVE_PUTENV */
-#ifdef MS_WINDOWS
-/*[clinic input]
-os.unsetenv
- name: unicode
- /
-
-Delete an environment variable.
-[clinic start generated code]*/
-
-static PyObject *
-os_unsetenv_impl(PyObject *module, PyObject *name)
-/*[clinic end generated code: output=54c4137ab1834f02 input=4d6a1747cc526d2f]*/
-{
- /* PyUnicode_AsWideCharString() rejects embedded null characters */
- wchar_t *name_str = PyUnicode_AsWideCharString(name, NULL);
- if (name_str == NULL) {
- return NULL;
- }
-
- BOOL ok = SetEnvironmentVariableW(name_str, NULL);
- PyMem_Free(name_str);
-
- if (!ok) {
- return PyErr_SetFromWindowsErr(0);
- }
-
-#ifdef PY_PUTENV_DICT
- /* Remove the key from putenv_dict;
- * this will cause it to be collected. This has to
- * happen after the real unsetenv() call because the
- * old value was still accessible until then.
- */
- if (PyDict_DelItem(_posixstate(module)->putenv_dict, name)) {
- /* really not much we can do; just leak */
- if (!PyErr_ExceptionMatches(PyExc_KeyError)) {
- return NULL;
- }
- PyErr_Clear();
- }
-#endif
-
- Py_RETURN_NONE;
-}
-/* repeat !defined(MS_WINDOWS) to workaround an Argument Clinic issue */
-#elif defined(HAVE_UNSETENV) && !defined(MS_WINDOWS)
+#ifdef HAVE_UNSETENV
/*[clinic input]
os.unsetenv
name: FSConverter