diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-24 13:05:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-24 13:05:48 (GMT) |
commit | b8d1262e8afe7b907b4a394a191739571092acdb (patch) | |
tree | 32ad60fdd1ee4b039233a25a0663f022f97b0e77 /Doc | |
parent | 161e7b36b1ea871a1352ccfc1d4f4c1eda76830f (diff) | |
download | cpython-b8d1262e8afe7b907b4a394a191739571092acdb.zip cpython-b8d1262e8afe7b907b4a394a191739571092acdb.tar.gz cpython-b8d1262e8afe7b907b4a394a191739571092acdb.tar.bz2 |
bpo-39395: putenv() and unsetenv() always available (GH-18135)
The os.putenv() and os.unsetenv() functions are now always available.
On non-Windows platforms, Python now requires setenv() and unsetenv()
functions to build.
Remove putenv_dict from posixmodule.c: it's not longer needed.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/os.rst | 43 | ||||
-rw-r--r-- | Doc/whatsnew/3.9.rst | 8 |
2 files changed, 27 insertions, 24 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index de3e560..f59423c 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -111,9 +111,9 @@ process and user. to the environment made after this time are not reflected in ``os.environ``, except for changes made by modifying ``os.environ`` directly. - If the platform supports the :func:`putenv` function, this mapping may be used - to modify the environment as well as query the environment. :func:`putenv` will - be called automatically when the mapping is modified. + This mapping may be used to modify the environment as well as query the + environment. :func:`putenv` will be called automatically when the mapping + is modified. On Unix, keys and values use :func:`sys.getfilesystemencoding` and ``'surrogateescape'`` error handler. Use :data:`environb` if you would like @@ -130,14 +130,10 @@ process and user. cause memory leaks. Refer to the system documentation for :c:func:`putenv`. - If :func:`putenv` is not provided, a modified copy of this mapping may be - passed to the appropriate process-creation functions to cause child processes - to use a modified environment. - - If the platform supports the :func:`unsetenv` function, you can delete items in - this mapping to unset environment variables. :func:`unsetenv` will be called - automatically when an item is deleted from ``os.environ``, and when - one of the :meth:`pop` or :meth:`clear` methods is called. + You can delete items in this mapping to unset environment variables. + :func:`unsetenv` will be called automatically when an item is deleted from + ``os.environ``, and when one of the :meth:`pop` or :meth:`clear` methods is + called. .. data:: environb @@ -439,17 +435,18 @@ process and user. changes to the environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - .. availability:: most flavors of Unix, Windows. + 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``. .. note:: On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may - cause memory leaks. Refer to the system documentation for putenv. + cause memory leaks. Refer to the system documentation for :c:func:`putenv`. - When :func:`putenv` is supported, 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``. + .. versionchanged:: 3.9 + The function is now always available. .. function:: setegid(egid) @@ -638,15 +635,13 @@ process and user. environment affect subprocesses started with :func:`os.system`, :func:`popen` or :func:`fork` and :func:`execv`. - When :func:`unsetenv` is supported, deletion of items in ``os.environ`` is - automatically translated into a corresponding call to :func:`unsetenv`; however, - calls to :func:`unsetenv` don't update ``os.environ``, so it is actually - preferable to delete items of ``os.environ``. - - .. availability:: most flavors of Unix, Windows. + Deletion of items in ``os.environ`` is automatically translated into a + corresponding call to :func:`unsetenv`; however, calls to :func:`unsetenv` + don't update ``os.environ``, so it is actually preferable to delete items of + ``os.environ``. .. versionchanged:: 3.9 - The function is now also available on Windows. + The function is now always available and is also available on Windows. .. _os-newstreams: diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 751562e..a4c4266 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -227,6 +227,10 @@ descriptors. The :func:`os.unsetenv` function is now also available on Windows. (Contributed by Victor Stinner in :issue:`39413`.) +The :func:`os.putenv` and :func:`os.unsetenv` functions are now always +available. +(Contributed by Victor Stinner in :issue:`39395`.) + poplib ------ @@ -331,6 +335,10 @@ Build and C API Changes Python 3.0, it has been ignored and unused. (Contributed by Jeroen Demeyer in :issue:`36974`.) +* On non-Windows platforms, the :c:func:`setenv` and :c:func:`unsetenv` + functions are now required to build Python. + (Contributed by Victor Stinner in :issue:`39395`.) + Deprecated ========== |