Message360451
> no need to remove that message.
I was discussing the wrong API. It's not directly relevant that Windows API functions that access the process environment are protected by the PEB lock. Python primarily uses [_w]environ, a copy of the process environment that's managed by the C runtime library (ucrt). os.putenv modifies this environment via _wputenv. (Ultimately this syncs with the process environment by calling SetEnvironmentVariableW.)
Functions that modify and read ucrt's environment are protected by a lock. But there's still a concern if multithreaded code reads or modifies [_w]environ concurrent to a _[w]putenv call. Also, [_w]getenv returns a pointer to the value in [_w]environ, so it has the same problem. A significant difference, however, is that _[w]putenv in ucrt is not POSIX compliant, since it copies the caller's string. Also, ucrt has safer [_w]getenv_s and _[w]dupenv_s functions that return a copy. |
|
Date |
User |
Action |
Args |
2020-01-22 08:11:06 | eryksun | set | recipients:
+ eryksun, gregory.p.smith, docs@python |
2020-01-22 08:11:06 | eryksun | set | messageid: <1579680666.57.0.709218108157.issue39375@roundup.psfhosted.org> |
2020-01-22 08:11:06 | eryksun | link | issue39375 messages |
2020-01-22 08:11:06 | eryksun | create | |
|