This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, serhiy.storchaka, vstinner
Date 2020-01-21.10:57:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579604270.05.0.0616126052682.issue39406@roundup.psfhosted.org>
In-reply-to
Content
> Maybe use SetEnvironmentVariable() on Windows? 

`_wputenv` keeps Python's copy of the environment block in sync with CRT's copy, which in turn calls `SetEnvironmentVariableW` to sync with process environment block. The CRT's copy of the environment excludes and disallows variable names that start with "=". Because the interpreter initializes `os.environ` from the CRT environment, Python has never included or allowed 'hidden' variables such as "=C:". 

Switching to calling `SetEnvironmentVariableW` directly won't affect `os.system` and `os.spawnv[e]`, since the CRT calls `CreateProcessW` without overriding the process environment. However, have you considered the consequences for extension modules and embedding applications that use the CRT environment (e.g. `getenv`, `_wgetenv`) if the interpreter stops syncing with it? 

The concern that `[_w]putenv` doesn't copy the string does not apply to Windows.
History
Date User Action Args
2020-01-21 10:57:50eryksunsetrecipients: + eryksun, vstinner, serhiy.storchaka
2020-01-21 10:57:50eryksunsetmessageid: <1579604270.05.0.0616126052682.issue39406@roundup.psfhosted.org>
2020-01-21 10:57:50eryksunlinkissue39406 messages
2020-01-21 10:57:49eryksuncreate