mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
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.
This commit is contained in:
parent
161e7b36b1
commit
b8d1262e8a
12 changed files with 52 additions and 154 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue