From ca90336dddcca82ef86484561efc0bf3c68080a1 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 1 Nov 2024 22:44:31 +0100 Subject: [PATCH] Update Doc/library/os.rst Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/library/os.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index caad2bf56c2413..45792f58d8234f 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -248,14 +248,18 @@ process and user. .. function:: reload_environ() - Update :data:`os.environ` and :data:`os.environb` with changes to the - current process environment made by :func:`os.putenv`, by - :func:`os.unsetenv`, or made outside Python in the same process. - - This function is not thread-safe. Calling it while the environment is - being modified in an other thread is an undefined behavior. Reading from - :data:`os.environ` or :data:`os.environb`, or calling :func:`os.getenv` - while reloading, may return an empty result. + The :data:`os.environ` and :data:`os.environb` mappings are a cache of + environment variables at the time that Python started. + As such, changes to the current process environment are not reflected + if made outside Python, or by :func:`os.putenv` or :func:`os.unsetenv`. + Use :func:`!os.reload_environ` to update :data:`os.environ` and :data:`os.environb` + with any such changes to the current process environment. + + .. warning:: + This function is not thread-safe. Calling it while the environment is + being modified in an other thread is an undefined behavior. Reading from + :data:`os.environ` or :data:`os.environb`, or calling :func:`os.getenv` + while reloading, may return an empty result. .. versionadded:: next