Message360386
> 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. |
|
Date |
User |
Action |
Args |
2020-01-21 10:57:50 | eryksun | set | recipients:
+ eryksun, vstinner, serhiy.storchaka |
2020-01-21 10:57:50 | eryksun | set | messageid: <1579604270.05.0.0616126052682.issue39406@roundup.psfhosted.org> |
2020-01-21 10:57:50 | eryksun | link | issue39406 messages |
2020-01-21 10:57:49 | eryksun | create | |
|