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, josh.r, paul.moore, r-or, roufique7, steve.dower, tim.golden, zach.ware
Date 2019-02-01.08:42:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549010564.82.0.103961572056.issue35862@roundup.psfhosted.org>
In-reply-to
Content
> 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"
History
Date User Action Args
2019-02-01 08:42:46eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, josh.r, roufique7, r-or
2019-02-01 08:42:44eryksunsetmessageid: <1549010564.82.0.103961572056.issue35862@roundup.psfhosted.org>
2019-02-01 08:42:44eryksunlinkissue35862 messages
2019-02-01 08:42:44eryksuncreate