Skip to content

Commit 190c9af

Browse files
vstinnertiran
authored andcommitted
pythongh-93103: Doc uses PyConfig rather than deprecated vars (python#96070)
The C API documentation now uses the new PyConfig API, rather than deprecated global configuration variables.
1 parent 12af353 commit 190c9af

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

Doc/c-api/intro.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ complete listing.
153153
.. c:macro:: Py_GETENV(s)
154154
155155
Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
156-
command line (i.e. if ``Py_IgnoreEnvironmentFlag`` is set).
156+
command line (see :c:member:`PyConfig.use_environment`).
157157

158158
.. c:macro:: Py_MAX(x, y)
159159

Doc/c-api/sys.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Operating System Utilities
167167
168168
.. versionchanged:: 3.8
169169
The function now uses the UTF-8 encoding on Windows if
170-
:c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
170+
:c:member:`PyConfig.legacy_windows_fs_encoding` is zero;
171171
172172
173173
.. c:function:: char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
@@ -209,7 +209,7 @@ Operating System Utilities
209209
210210
.. versionchanged:: 3.8
211211
The function now uses the UTF-8 encoding on Windows if
212-
:c:data:`Py_LegacyWindowsFSEncodingFlag` is zero.
212+
:c:member:`PyConfig.legacy_windows_fs_encoding` is zero.
213213
214214
215215
.. _systemfunctions:

Doc/c-api/veryhigh.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ the same library that the Python runtime is using.
3939
4040
Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
4141
function will not return ``1``, but exit the process, as long as
42-
``Py_InspectFlag`` is not set.
42+
:c:member:`PyConfig.inspect` is zero.
4343
4444
4545
.. c:function:: int Py_BytesMain(int argc, char **argv)
@@ -95,7 +95,7 @@ the same library that the Python runtime is using.
9595
9696
Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
9797
function will not return ``-1``, but exit the process, as long as
98-
``Py_InspectFlag`` is not set.
98+
:c:member:`PyConfig.inspect` is zero.
9999
100100
101101
.. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename)

Doc/library/ctypes.rst

+5-7
Original file line numberDiff line numberDiff line change
@@ -1068,18 +1068,16 @@ Accessing values exported from dlls
10681068
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10691069

10701070
Some shared libraries not only export functions, they also export variables. An
1071-
example in the Python library itself is the :c:data:`Py_OptimizeFlag`, an integer
1072-
set to 0, 1, or 2, depending on the :option:`-O` or :option:`-OO` flag given on
1073-
startup.
1071+
example in the Python library itself is the :c:data:`Py_Version`, Python
1072+
runtime version number encoded in a single constant integer.
10741073

10751074
:mod:`ctypes` can access values like this with the :meth:`in_dll` class methods of
10761075
the type. *pythonapi* is a predefined symbol giving access to the Python C
10771076
api::
10781077

1079-
>>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
1080-
>>> print(opt_flag)
1081-
c_long(0)
1082-
>>>
1078+
>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
1079+
>>> print(hex(version.value))
1080+
0x30c00a0
10831081

10841082
If the interpreter would have been started with :option:`-O`, the sample would
10851083
have printed ``c_long(1)``, or ``c_long(2)`` if :option:`-OO` would have been

0 commit comments

Comments
 (0)