diff options
author | Victor Stinner <vstinner@python.org> | 2022-05-23 12:56:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 12:56:35 (GMT) |
commit | 764e83db8536ece49550f8a44f0525cb031369a4 (patch) | |
tree | e82955627c0f6adf9008759b2f2d7a8933da0407 /Doc/c-api/init.rst | |
parent | 760ec8940aabd6a7fc471bd913ea1ac501cc604b (diff) | |
download | cpython-764e83db8536ece49550f8a44f0525cb031369a4.zip cpython-764e83db8536ece49550f8a44f0525cb031369a4.tar.gz cpython-764e83db8536ece49550f8a44f0525cb031369a4.tar.bz2 |
gh-93103: Deprecate global configuration variable (#93104)
Deprecate global configuration variables, like
Py_IgnoreEnvironmentFlag, in the documentation: the
Py_InitializeFromConfig() API should be instead.
Diffstat (limited to 'Doc/c-api/init.rst')
-rw-r--r-- | Doc/c-api/init.rst | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index d495495..038498f 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -83,52 +83,93 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. .. 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 :class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater or equal to ``2``. Set by the :option:`-b` option. + .. deprecated:: 3.12 + .. 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 options). Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment variable. + .. deprecated:: 3.12 + .. 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 import of source modules. Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable. + .. deprecated:: 3.12 + .. 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 :c:func:`Py_GetPath`. Private flag used by ``_freeze_module`` and ``frozenmain`` programs. + .. deprecated:: 3.12 + .. 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 a non-empty string. If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment variable to initialize the secret hash seed. + .. deprecated:: 3.12 + .. 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. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. Set by the :option:`-E` and :option:`-I` options. + .. deprecated:: 3.12 + .. 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, enter interactive mode after executing the script or the command, even when :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 variable. + .. deprecated:: 3.12 + .. 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. + .. deprecated:: 3.12 + .. 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 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 + .. deprecated:: 3.12 + .. 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 handler, instead of the UTF-8 encoding with ``surrogatepass`` 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. + .. deprecated:: 3.12 + .. 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 :class:`WindowsConsoleIO` for :mod:`sys` standard streams. @@ -174,8 +239,14 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. .. availability:: Windows. + .. deprecated:: 3.12 + .. 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 manipulations of :data:`sys.path` that it entails. Also disable these 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. + .. deprecated:: 3.12 + .. 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 :data:`sys.path`. Set by the :option:`-s` and :option:`-I` options, and the :envvar:`PYTHONNOUSERSITE` environment variable. + .. deprecated:: 3.12 + .. 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 variable. + .. deprecated:: 3.12 + .. 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. Set by the :option:`-q` option. .. versionadded:: 3.2 + .. deprecated:: 3.12 + .. 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. Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED` environment variable. + .. deprecated:: 3.12 + .. 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 (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 @@ -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 variable. + .. deprecated:: 3.12 + 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 fatal error if the initialization fails. + Use the :c:func:`Py_InitializeFromConfig` function to customize the + :ref:`Python Initialization Configuration <init-config>`. + .. note:: 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. @@ -264,6 +370,9 @@ Initializing and finalizing the interpreter *initsigs* is ``0``, it skips initialization registration of signal handlers, which 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() |