Eryk Sun <eryk...@gmail.com> added the comment:

> Because sometimes when a process is implicitly started by some 3rd 
> party library (i.e. COM via pythonwin here) the "old", unchanged 
> environment is retained as the process itself doesn't care if 
> os.environ was changed or not, the original environment cannot 
> be modified.

What "old" environment are we talking about? The os.environ mapping is 
implemented to immediately modify the process environment block. For example:

Python:

    >>> os.environ['SPAM'] = 'EGGS'

Debugger:

    Breakpoint 0 hit
    KERNELBASE!SetEnvironmentVariableW:
    00007fff`8ae3ee30 4053            push    rbx
    0:000> kc 6
    Call Site
    KERNELBASE!SetEnvironmentVariableW
    ucrtbase!common_set_variable_in_environment_nolock<wchar_t>
    ucrtbase!common_putenv_nolock<wchar_t>
    ucrtbase!common_putenv<wchar_t>
    python37!os_putenv_impl
    python37!os_putenv

    0:000> du @rcx
    00000215`70dd57c0  "SPAM"
    0:000> du @rdx
    00000215`70dd57ca  "EGGS"

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35862>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to