Skip to content

gh-85133: Add that getenv uses os.environ #91874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ process and user.
.. function:: getenv(key, default=None)

Return the value of the environment variable *key* if it exists, or
*default* if it doesn't. *key*, *default* and the result are str.
*default* if it doesn't. *key*, *default* and the result are str. Note that
since :func:`getenv` uses ``os.environ``, the mapping of :func:`getenv` is
similarly also captured on import, and the function may not reflect
future environment changes.

On Unix, keys and values are decoded with :func:`sys.getfilesystemencoding`
and ``'surrogateescape'`` error handler. Use :func:`os.getenvb` if you
Expand Down Expand Up @@ -514,7 +517,8 @@ process and user.
Assignments to items in ``os.environ`` are automatically translated into
corresponding calls to :func:`putenv`; however, calls to :func:`putenv`
don't update ``os.environ``, so it is actually preferable to assign to items
of ``os.environ``.
of ``os.environ``. This also applies to :func:`getenv`, which uses
``os.environ`` in its implementation.

.. note::

Expand Down