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
10 changes: 7 additions & 3 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ process and user.
.. function:: getenvb(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 bytes.
*default* if it doesn't. *key*, *default* and the result are bytes. Note that
since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is
similarly also captured on import, and the function may not reflect
future environment changes.


:func:`getenvb` is only available if :data:`supports_bytes_environ`
is ``True``.
Expand Down Expand Up @@ -517,8 +521,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``. This also applies to :func:`getenv` and :func:`getenvb`, which uses
``os.environ`` in its implementation.
of ``os.environ``. This also applies to :func:`getenv` and :func:`getenvb`, which
respectively use ``os.environ`` and ``os.environb`` in their implementations.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative wording can be something like

'This also applies to getenv, which uses os.environ in its implementation (and likewise for getenvb and environb).'


.. note::

Expand Down