This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.
Activity
itamaro commented on Jun 1, 2024
the behavior matches the documented behavior:
so this is not a bug, but a feature request.
please propose this on the Python discuss ideas category first!
eryksun commented on Jun 1, 2024
This new feature would have to be implemented in C in "Modules/posixmodule.c". That's why I added the "extension-modules" label.
yurivict commented on Jun 2, 2024
https://discuss.python.org/t/feature-request-method-to-refresh-os-environ/54774
vstinner commented on Jun 5, 2024
I close this issue as a duplicate of #120057