Skip to content

Commit

Permalink
Update Doc/library/os.rst
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <[email protected]>
  • Loading branch information
vstinner and AA-Turner authored Nov 1, 2024
1 parent fde06e9 commit ca90336
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ca90336

Please sign in to comment.