Serhiy:
> Maybe use SetEnvironmentVariable() on Windows?
In bpo-39413, I implemented os.unsetenv() on Windows using SetEnvironmentVariable(), but Eryk reported that SetEnvironmentVariable() does not update the CRT API (_environ, _wenviron, getenv, etc.). So I reverted my change. See bpo-39413 for the details.
Eryk:
> Windows ucrt copies the buffer that's passed to _[w]putenv.
Thank you for checking manually. I pushed commit 0852c7dd52ac42e7843ddfef44571494e4c86070 to avoid putenv_dict on Windows.