mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
gh-93103: Deprecate global configuration variable (#93104)
Deprecate global configuration variables, like Py_IgnoreEnvironmentFlag, in the documentation: the Py_InitializeFromConfig() API should be instead.
This commit is contained in:
parent
760ec8940a
commit
764e83db85
3 changed files with 123 additions and 7 deletions
|
@ -83,52 +83,93 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
|
|
||||||
.. c:var:: int Py_BytesWarningFlag
|
.. c:var:: int Py_BytesWarningFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.bytes_warning` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Issue a warning when comparing :class:`bytes` or :class:`bytearray` with
|
Issue a warning when comparing :class:`bytes` or :class:`bytearray` with
|
||||||
:class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater
|
:class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater
|
||||||
or equal to ``2``.
|
or equal to ``2``.
|
||||||
|
|
||||||
Set by the :option:`-b` option.
|
Set by the :option:`-b` option.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_DebugFlag
|
.. c:var:: int Py_DebugFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.parser_debug` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Turn on parser debugging output (for expert only, depending on compilation
|
Turn on parser debugging output (for expert only, depending on compilation
|
||||||
options).
|
options).
|
||||||
|
|
||||||
Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment
|
Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_DontWriteBytecodeFlag
|
.. c:var:: int Py_DontWriteBytecodeFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.write_bytecode` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
If set to non-zero, Python won't try to write ``.pyc`` files on the
|
If set to non-zero, Python won't try to write ``.pyc`` files on the
|
||||||
import of source modules.
|
import of source modules.
|
||||||
|
|
||||||
Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE`
|
Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE`
|
||||||
environment variable.
|
environment variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_FrozenFlag
|
.. c:var:: int Py_FrozenFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.pathconfig_warnings` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Suppress error messages when calculating the module search path in
|
Suppress error messages when calculating the module search path in
|
||||||
:c:func:`Py_GetPath`.
|
:c:func:`Py_GetPath`.
|
||||||
|
|
||||||
Private flag used by ``_freeze_module`` and ``frozenmain`` programs.
|
Private flag used by ``_freeze_module`` and ``frozenmain`` programs.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_HashRandomizationFlag
|
.. c:var:: int Py_HashRandomizationFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.hash_seed` and :c:member:`PyConfig.use_hash_seed` should
|
||||||
|
be used instead, see :ref:`Python Initialization Configuration
|
||||||
|
<init-config>`.
|
||||||
|
|
||||||
Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to
|
Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to
|
||||||
a non-empty string.
|
a non-empty string.
|
||||||
|
|
||||||
If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment
|
If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment
|
||||||
variable to initialize the secret hash seed.
|
variable to initialize the secret hash seed.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_IgnoreEnvironmentFlag
|
.. c:var:: int Py_IgnoreEnvironmentFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.use_environment` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Ignore all :envvar:`PYTHON*` environment variables, e.g.
|
Ignore all :envvar:`PYTHON*` environment variables, e.g.
|
||||||
:envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set.
|
:envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set.
|
||||||
|
|
||||||
Set by the :option:`-E` and :option:`-I` options.
|
Set by the :option:`-E` and :option:`-I` options.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_InspectFlag
|
.. c:var:: int Py_InspectFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.inspect` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
When a script is passed as first argument or the :option:`-c` option is used,
|
When a script is passed as first argument or the :option:`-c` option is used,
|
||||||
enter interactive mode after executing the script or the command, even when
|
enter interactive mode after executing the script or the command, even when
|
||||||
:data:`sys.stdin` does not appear to be a terminal.
|
:data:`sys.stdin` does not appear to be a terminal.
|
||||||
|
@ -136,12 +177,24 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment
|
Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_InteractiveFlag
|
.. c:var:: int Py_InteractiveFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.interactive` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Set by the :option:`-i` option.
|
Set by the :option:`-i` option.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_IsolatedFlag
|
.. c:var:: int Py_IsolatedFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.isolated` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Run Python in isolated mode. In isolated mode :data:`sys.path` contains
|
Run Python in isolated mode. In isolated mode :data:`sys.path` contains
|
||||||
neither the script's directory nor the user's site-packages directory.
|
neither the script's directory nor the user's site-packages directory.
|
||||||
|
|
||||||
|
@ -149,8 +202,14 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
.. versionadded:: 3.4
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_LegacyWindowsFSEncodingFlag
|
.. c:var:: int Py_LegacyWindowsFSEncodingFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyPreConfig.legacy_windows_fs_encoding` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error
|
If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error
|
||||||
handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler,
|
handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler,
|
||||||
for the :term:`filesystem encoding and error handler`.
|
for the :term:`filesystem encoding and error handler`.
|
||||||
|
@ -162,8 +221,14 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
|
|
||||||
.. availability:: Windows.
|
.. availability:: Windows.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_LegacyWindowsStdioFlag
|
.. c:var:: int Py_LegacyWindowsStdioFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.legacy_windows_stdio` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
If the flag is non-zero, use :class:`io.FileIO` instead of
|
If the flag is non-zero, use :class:`io.FileIO` instead of
|
||||||
:class:`WindowsConsoleIO` for :mod:`sys` standard streams.
|
:class:`WindowsConsoleIO` for :mod:`sys` standard streams.
|
||||||
|
|
||||||
|
@ -174,8 +239,14 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
|
|
||||||
.. availability:: Windows.
|
.. availability:: Windows.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_NoSiteFlag
|
.. c:var:: int Py_NoSiteFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.site_import` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Disable the import of the module :mod:`site` and the site-dependent
|
Disable the import of the module :mod:`site` and the site-dependent
|
||||||
manipulations of :data:`sys.path` that it entails. Also disable these
|
manipulations of :data:`sys.path` that it entails. Also disable these
|
||||||
manipulations if :mod:`site` is explicitly imported later (call
|
manipulations if :mod:`site` is explicitly imported later (call
|
||||||
|
@ -183,36 +254,66 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
|
|
||||||
Set by the :option:`-S` option.
|
Set by the :option:`-S` option.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_NoUserSiteDirectory
|
.. c:var:: int Py_NoUserSiteDirectory
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.user_site_directory` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Don't add the :data:`user site-packages directory <site.USER_SITE>` to
|
Don't add the :data:`user site-packages directory <site.USER_SITE>` to
|
||||||
:data:`sys.path`.
|
:data:`sys.path`.
|
||||||
|
|
||||||
Set by the :option:`-s` and :option:`-I` options, and the
|
Set by the :option:`-s` and :option:`-I` options, and the
|
||||||
:envvar:`PYTHONNOUSERSITE` environment variable.
|
:envvar:`PYTHONNOUSERSITE` environment variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_OptimizeFlag
|
.. c:var:: int Py_OptimizeFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.optimization_level` should be used instead, see
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment
|
Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_QuietFlag
|
.. c:var:: int Py_QuietFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.quiet` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Don't display the copyright and version messages even in interactive mode.
|
Don't display the copyright and version messages even in interactive mode.
|
||||||
|
|
||||||
Set by the :option:`-q` option.
|
Set by the :option:`-q` option.
|
||||||
|
|
||||||
.. versionadded:: 3.2
|
.. versionadded:: 3.2
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_UnbufferedStdioFlag
|
.. c:var:: int Py_UnbufferedStdioFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.buffered_stdio` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Force the stdout and stderr streams to be unbuffered.
|
Force the stdout and stderr streams to be unbuffered.
|
||||||
|
|
||||||
Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED`
|
Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED`
|
||||||
environment variable.
|
environment variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
.. c:var:: int Py_VerboseFlag
|
.. c:var:: int Py_VerboseFlag
|
||||||
|
|
||||||
|
This API is kept for backward compatibility: setting
|
||||||
|
:c:member:`PyConfig.verbose` should be used instead, see :ref:`Python
|
||||||
|
Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
Print a message each time a module is initialized, showing the place
|
Print a message each time a module is initialized, showing the place
|
||||||
(filename or built-in module) from which it is loaded. If greater or equal
|
(filename or built-in module) from which it is loaded. If greater or equal
|
||||||
to ``2``, print a message for each file that is checked for when
|
to ``2``, print a message for each file that is checked for when
|
||||||
|
@ -221,6 +322,8 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
|
||||||
Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment
|
Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
|
|
||||||
Initializing and finalizing the interpreter
|
Initializing and finalizing the interpreter
|
||||||
===========================================
|
===========================================
|
||||||
|
@ -253,6 +356,9 @@ Initializing and finalizing the interpreter
|
||||||
(without calling :c:func:`Py_FinalizeEx` first). There is no return value; it is a
|
(without calling :c:func:`Py_FinalizeEx` first). There is no return value; it is a
|
||||||
fatal error if the initialization fails.
|
fatal error if the initialization fails.
|
||||||
|
|
||||||
|
Use the :c:func:`Py_InitializeFromConfig` function to customize the
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
On Windows, changes the console mode from ``O_TEXT`` to ``O_BINARY``, which will
|
On Windows, changes the console mode from ``O_TEXT`` to ``O_BINARY``, which will
|
||||||
also affect non-Python uses of the console using the C Runtime.
|
also affect non-Python uses of the console using the C Runtime.
|
||||||
|
@ -264,6 +370,9 @@ Initializing and finalizing the interpreter
|
||||||
*initsigs* is ``0``, it skips initialization registration of signal handlers, which
|
*initsigs* is ``0``, it skips initialization registration of signal handlers, which
|
||||||
might be useful when Python is embedded.
|
might be useful when Python is embedded.
|
||||||
|
|
||||||
|
Use the :c:func:`Py_InitializeFromConfig` function to customize the
|
||||||
|
:ref:`Python Initialization Configuration <init-config>`.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: int Py_IsInitialized()
|
.. c:function:: int Py_IsInitialized()
|
||||||
|
|
||||||
|
|
|
@ -835,8 +835,10 @@ PyConfig
|
||||||
|
|
||||||
* Set :c:member:`~PyConfig.safe_path` to ``1``:
|
* Set :c:member:`~PyConfig.safe_path` to ``1``:
|
||||||
don't prepend a potentially unsafe path to :data:`sys.path` at Python
|
don't prepend a potentially unsafe path to :data:`sys.path` at Python
|
||||||
startup.
|
startup, such as the current directory, the script's directory or an
|
||||||
* Set :c:member:`~PyConfig.use_environment` to ``0``.
|
empty string.
|
||||||
|
* Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON``
|
||||||
|
environment variables.
|
||||||
* Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user
|
* Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user
|
||||||
site directory to :data:`sys.path`.
|
site directory to :data:`sys.path`.
|
||||||
* Python REPL doesn't import :mod:`readline` nor enable default readline
|
* Python REPL doesn't import :mod:`readline` nor enable default readline
|
||||||
|
@ -846,7 +848,8 @@ PyConfig
|
||||||
|
|
||||||
Default: ``0`` in Python mode, ``1`` in isolated mode.
|
Default: ``0`` in Python mode, ``1`` in isolated mode.
|
||||||
|
|
||||||
See also :c:member:`PyPreConfig.isolated`.
|
See also the :ref:`Isolated Configuration <init-isolated-conf>` and
|
||||||
|
:c:member:`PyPreConfig.isolated`.
|
||||||
|
|
||||||
.. c:member:: int legacy_windows_stdio
|
.. c:member:: int legacy_windows_stdio
|
||||||
|
|
||||||
|
@ -1177,13 +1180,13 @@ PyConfig
|
||||||
imported, showing the place (filename or built-in module) from which
|
imported, showing the place (filename or built-in module) from which
|
||||||
it is loaded.
|
it is loaded.
|
||||||
|
|
||||||
If greater or equal to ``2``, print a message for each file that is checked
|
If greater than or equal to ``2``, print a message for each file that is
|
||||||
for when searching for a module. Also provides information on module
|
checked for when searching for a module. Also provides information on
|
||||||
cleanup at exit.
|
module cleanup at exit.
|
||||||
|
|
||||||
Incremented by the :option:`-v` command line option.
|
Incremented by the :option:`-v` command line option.
|
||||||
|
|
||||||
Set to the :envvar:`PYTHONVERBOSE` environment variable value.
|
Set by the :envvar:`PYTHONVERBOSE` environment variable value.
|
||||||
|
|
||||||
Default: ``0``.
|
Default: ``0``.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Deprecate global configuration variables, like
|
||||||
|
:c:var:`Py_IgnoreEnvironmentFlag`, in the documentation: the
|
||||||
|
:c:func:`Py_InitializeFromConfig` API should be instead. Patch by Victor
|
||||||
|
Stinner.
|
Loading…
Add table
Add a link
Reference in a new issue