]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93103: Doc uses PyConfig rather than deprecated vars (#96070)
authorVictor Stinner <vstinner@python.org>
Thu, 18 Aug 2022 14:58:38 +0000 (16:58 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Aug 2022 14:58:38 +0000 (16:58 +0200)
The C API documentation now uses the new PyConfig API, rather than
deprecated global configuration variables.

Doc/c-api/intro.rst
Doc/c-api/sys.rst
Doc/c-api/veryhigh.rst
Doc/library/ctypes.rst

index d9fcd0de1fec6dbd8536a7e2019160830425ef05..557ccfc052343e67e7e2d4e0b6629c36a2f27595 100644 (file)
@@ -153,7 +153,7 @@ complete listing.
 .. c:macro:: Py_GETENV(s)
 
    Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
-   command line (i.e. if ``Py_IgnoreEnvironmentFlag`` is set).
+   command line (see :c:member:`PyConfig.use_environment`).
 
 .. c:macro:: Py_MAX(x, y)
 
index 32c2bc8a0880ea678462bca8f73a572b5bc9e07a..11d5e0e03ec0983cf66296e9fab7e8c2d17e0a4f 100644 (file)
@@ -167,7 +167,7 @@ Operating System Utilities
 
    .. versionchanged:: 3.8
       The function now uses the UTF-8 encoding on Windows if
-      :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
+      :c:member:`PyConfig.legacy_windows_fs_encoding` is zero;
 
 
 .. c:function:: char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
@@ -209,7 +209,7 @@ Operating System Utilities
 
    .. versionchanged:: 3.8
       The function now uses the UTF-8 encoding on Windows if
-      :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero.
+      :c:member:`PyConfig.legacy_windows_fs_encoding` is zero.
 
 
 .. _systemfunctions:
index 7bd47bb9c660a662fba9e0a0fb6ad68acf0238f4..b17818e35ed9cf3db16c263910b4f09a444463d1 100644 (file)
@@ -39,7 +39,7 @@ the same library that the Python runtime is using.
 
    Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
    function will not return ``1``, but exit the process, as long as
-   ``Py_InspectFlag`` is not set.
+   :c:member:`PyConfig.inspect` is zero.
 
 
 .. c:function:: int Py_BytesMain(int argc, char **argv)
@@ -95,7 +95,7 @@ the same library that the Python runtime is using.
 
    Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
    function will not return ``-1``, but exit the process, as long as
-   ``Py_InspectFlag`` is not set.
+   :c:member:`PyConfig.inspect` is zero.
 
 
 .. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename)
index 475737144d40c63669c57b9b673b5c280e4eeb62..9546696e1c3d76a29f103dd54f260870fdc7f0da 100644 (file)
@@ -1068,18 +1068,16 @@ Accessing values exported from dlls
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Some shared libraries not only export functions, they also export variables. An
-example in the Python library itself is the :c:data:`Py_OptimizeFlag`, an integer
-set to 0, 1, or 2, depending on the :option:`-O` or :option:`-OO` flag given on
-startup.
+example in the Python library itself is the :c:data:`Py_Version`, Python
+runtime version number encoded in a single constant integer.
 
 :mod:`ctypes` can access values like this with the :meth:`in_dll` class methods of
 the type.  *pythonapi* is a predefined symbol giving access to the Python C
 api::
 
-   >>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
-   >>> print(opt_flag)
-   c_long(0)
-   >>>
+   >>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
+   >>> print(hex(version.value))
+   0x30c00a0
 
 If the interpreter would have been started with :option:`-O`, the sample would
 have printed ``c_long(1)``, or ``c_long(2)`` if :option:`-OO` would have been