Skip to content

Commit ea58fea

Browse files
Enhance PyConfig documentation (GH-92394)
(cherry picked from commit 7b9803f) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 5e2e9c4 commit ea58fea

File tree

1 file changed

+46
-37
lines changed

1 file changed

+46
-37
lines changed

Doc/c-api/init_config.rst

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ PyWideStringList
9797
If *index* is greater than or equal to *list* length, append *item* to
9898
*list*.
9999
100-
*index* must be greater than or equal to 0.
100+
*index* must be greater than or equal to ``0``.
101101
102102
Python must be preinitialized to call this function.
103103
@@ -256,18 +256,18 @@ PyPreConfig
256256
257257
Set the LC_CTYPE locale to the user preferred locale?
258258
259-
If equals to 0, set :c:member:`~PyPreConfig.coerce_c_locale` and
260-
:c:member:`~PyPreConfig.coerce_c_locale_warn` members to 0.
259+
If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and
260+
:c:member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``.
261261
262262
See the :term:`locale encoding`.
263263
264264
Default: ``1`` in Python config, ``0`` in isolated config.
265265
266266
.. c:member:: int coerce_c_locale
267267
268-
If equals to 2, coerce the C locale.
268+
If equals to ``2``, coerce the C locale.
269269
270-
If equals to 1, read the LC_CTYPE locale to decide if it should be
270+
If equals to ``1``, read the LC_CTYPE locale to decide if it should be
271271
coerced.
272272
273273
See the :term:`locale encoding`.
@@ -282,8 +282,8 @@ PyPreConfig
282282
283283
.. c:member:: int dev_mode
284284
285-
If non-zero, enables the :ref:`Python Development Mode <devmode>`:
286-
see :c:member:`PyConfig.dev_mode`.
285+
:ref:`Python Development Mode <devmode>`: see
286+
:c:member:`PyConfig.dev_mode`.
287287
288288
Default: ``-1`` in Python mode, ``0`` in isolated mode.
289289
@@ -329,8 +329,10 @@ PyPreConfig
329329
330330
If non-zero, enable the :ref:`Python UTF-8 Mode <utf8-mode>`.
331331
332-
Set by the :option:`-X utf8 <-X>` command line option and the
333-
:envvar:`PYTHONUTF8` environment variable.
332+
Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option
333+
and the :envvar:`PYTHONUTF8` environment variable.
334+
335+
Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``.
334336
335337
Default: ``-1`` in Python config and ``0`` in isolated config.
336338
@@ -555,7 +557,7 @@ PyConfig
555557
* Otherwise (``python -c code`` and ``python``), prepend an empty string,
556558
which means the current working directory.
557559
558-
Set to 1 by the :option:`-P` command line option and the
560+
Set to ``1`` by the :option:`-P` command line option and the
559561
:envvar:`PYTHONSAFEPATH` environment variable.
560562
561563
Default: ``0`` in Python config, ``1`` in isolated config.
@@ -592,10 +594,10 @@ PyConfig
592594
593595
.. c:member:: int buffered_stdio
594596
595-
If equals to 0 and :c:member:`~PyConfig.configure_c_stdio` is non-zero,
597+
If equals to ``0`` and :c:member:`~PyConfig.configure_c_stdio` is non-zero,
596598
disable buffering on the C streams stdout and stderr.
597599
598-
Set to 0 by the :option:`-u` command line option and the
600+
Set to ``0`` by the :option:`-u` command line option and the
599601
:envvar:`PYTHONUNBUFFERED` environment variable.
600602
601603
stdin is always opened in buffered mode.
@@ -604,11 +606,11 @@ PyConfig
604606
605607
.. c:member:: int bytes_warning
606608
607-
If equals to 1, issue a warning when comparing :class:`bytes` or
609+
If equals to ``1``, issue a warning when comparing :class:`bytes` or
608610
:class:`bytearray` with :class:`str`, or comparing :class:`bytes` with
609611
:class:`int`.
610612
611-
If equal or greater to 2, raise a :exc:`BytesWarning` exception in these
613+
If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these
612614
cases.
613615
614616
Incremented by the :option:`-b` command line option.
@@ -671,6 +673,9 @@ PyConfig
671673
672674
If non-zero, enable the :ref:`Python Development Mode <devmode>`.
673675
676+
Set to ``1`` by the :option:`-X dev <-X>` option and the
677+
:envvar:`PYTHONDEVMODE` environment variable.
678+
674679
Default: ``-1`` in Python mode, ``0`` in isolated mode.
675680
676681
.. c:member:: int dump_refs
@@ -800,7 +805,7 @@ PyConfig
800805
801806
Enter interactive mode after executing a script or a command.
802807
803-
If greater than 0, enable inspect: when a script is passed as first
808+
If greater than ``0``, enable inspect: when a script is passed as first
804809
argument or the -c option is used, enter interactive mode after executing
805810
the script or the command, even when :data:`sys.stdin` does not appear to
806811
be a terminal.
@@ -818,25 +823,27 @@ PyConfig
818823
819824
.. c:member:: int interactive
820825
821-
If greater than 0, enable the interactive mode (REPL).
826+
If greater than ``0``, enable the interactive mode (REPL).
822827
823828
Incremented by the :option:`-i` command line option.
824829
825830
Default: ``0``.
826831
827832
.. c:member:: int isolated
828833
829-
If greater than 0, enable isolated mode:
834+
If greater than ``0``, enable isolated mode:
830835
831-
* Set :c:member:`~PyConfig.safe_path` to 1:
836+
* Set :c:member:`~PyConfig.safe_path` to ``1``:
832837
don't prepend a potentially unsafe path to :data:`sys.path` at Python
833838
startup.
834-
* Set :c:member:`~PyConfig.use_environment` to 0.
835-
* Set :c:member:`~PyConfig.user_site_directory` to 0: don't add the user
839+
* Set :c:member:`~PyConfig.use_environment` to ``0``.
840+
* Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user
836841
site directory to :data:`sys.path`.
837842
* Python REPL doesn't import :mod:`readline` nor enable default readline
838843
configuration on interactive prompts.
839844
845+
Set to ``1`` by the :option:`-I` command line option.
846+
840847
Default: ``0`` in Python mode, ``1`` in isolated mode.
841848
842849
See also :c:member:`PyPreConfig.isolated`.
@@ -906,7 +913,7 @@ PyConfig
906913
907914
Module search paths: :data:`sys.path`.
908915
909-
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0,
916+
If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``,
910917
:c:func:`Py_InitializeFromConfig` will replace
911918
:c:member:`~PyConfig.module_search_paths` and sets
912919
:c:member:`~PyConfig.module_search_paths_set` to ``1``.
@@ -970,7 +977,7 @@ PyConfig
970977
971978
.. c:member:: int parser_debug
972979
973-
Parser debug mode. If greater than 0, turn on parser debugging output (for expert only, depending
980+
Parser debug mode. If greater than ``0``, turn on parser debugging output (for expert only, depending
974981
on compilation options).
975982
976983
Incremented by the :option:`-d` command line option. Set to the
@@ -981,7 +988,7 @@ PyConfig
981988
.. c:member:: int pathconfig_warnings
982989
983990
If non-zero, calculation of path configuration is allowed to log
984-
warnings into ``stderr``. If equals to 0, suppress these warnings.
991+
warnings into ``stderr``. If equals to ``0``, suppress these warnings.
985992
986993
Default: ``1`` in Python mode, ``0`` in isolated mode.
987994
@@ -1031,7 +1038,7 @@ PyConfig
10311038
10321039
.. c:member:: int quiet
10331040
1034-
Quiet mode. If greater than 0, don't display the copyright and version at
1041+
Quiet mode. If greater than ``0``, don't display the copyright and version at
10351042
Python startup in interactive mode.
10361043
10371044
Incremented by the :option:`-q` command line option.
@@ -1071,7 +1078,7 @@ PyConfig
10711078
10721079
Show total reference count at exit?
10731080
1074-
Set to 1 by :option:`-X showrefcount <-X>` command line option.
1081+
Set to ``1`` by :option:`-X showrefcount <-X>` command line option.
10751082
10761083
Need a :ref:`debug build of Python <debug-build>` (the ``Py_REF_DEBUG``
10771084
macro must be defined).
@@ -1150,6 +1157,8 @@ PyConfig
11501157
If equals to zero, ignore the :ref:`environment variables
11511158
<using-on-envvars>`.
11521159
1160+
Set to ``0`` by the :option:`-E` environment variable.
1161+
11531162
Default: ``1`` in Python config and ``0`` in isolated config.
11541163
11551164
.. c:member:: int user_site_directory
@@ -1164,11 +1173,11 @@ PyConfig
11641173
11651174
.. c:member:: int verbose
11661175
1167-
Verbose mode. If greater than 0, print a message each time a module is
1176+
Verbose mode. If greater than ``0``, print a message each time a module is
11681177
imported, showing the place (filename or built-in module) from which
11691178
it is loaded.
11701179
1171-
If greater or equal to 2, print a message for each file that is checked
1180+
If greater or equal to ``2``, print a message for each file that is checked
11721181
for when searching for a module. Also provides information on module
11731182
cleanup at exit.
11741183
@@ -1199,7 +1208,7 @@ PyConfig
11991208
12001209
.. c:member:: int write_bytecode
12011210
1202-
If equal to 0, Python won't try to write ``.pyc`` files on the import of
1211+
If equal to ``0``, Python won't try to write ``.pyc`` files on the import of
12031212
source modules.
12041213
12051214
Set to ``0`` by the :option:`-B` command line option and the
@@ -1400,18 +1409,18 @@ Python Path Configuration
14001409
14011410
If at least one "output field" is not set, Python calculates the path
14021411
configuration to fill unset fields. If
1403-
:c:member:`~PyConfig.module_search_paths_set` is equal to 0,
1412+
:c:member:`~PyConfig.module_search_paths_set` is equal to ``0``,
14041413
:c:member:`~PyConfig.module_search_paths` is overridden and
1405-
:c:member:`~PyConfig.module_search_paths_set` is set to 1.
1414+
:c:member:`~PyConfig.module_search_paths_set` is set to ``1``.
14061415
14071416
It is possible to completely ignore the function calculating the default
14081417
path configuration by setting explicitly all path configuration output
14091418
fields listed above. A string is considered as set even if it is non-empty.
14101419
``module_search_paths`` is considered as set if
1411-
``module_search_paths_set`` is set to 1. In this case, path
1420+
``module_search_paths_set`` is set to ``1``. In this case, path
14121421
configuration input fields are ignored as well.
14131422
1414-
Set :c:member:`~PyConfig.pathconfig_warnings` to 0 to suppress warnings when
1423+
Set :c:member:`~PyConfig.pathconfig_warnings` to ``0`` to suppress warnings when
14151424
calculating the path configuration (Unix only, Windows does not log any warning).
14161425
14171426
If :c:member:`~PyConfig.base_prefix` or :c:member:`~PyConfig.base_exec_prefix`
@@ -1445,10 +1454,10 @@ The following configuration files are used by the path configuration:
14451454
14461455
If a ``._pth`` file is present:
14471456
1448-
* Set :c:member:`~PyConfig.isolated` to 1.
1449-
* Set :c:member:`~PyConfig.use_environment` to 0.
1450-
* Set :c:member:`~PyConfig.site_import` to 0.
1451-
* Set :c:member:`~PyConfig.safe_path` to 1.
1457+
* Set :c:member:`~PyConfig.isolated` to ``1``.
1458+
* Set :c:member:`~PyConfig.use_environment` to ``0``.
1459+
* Set :c:member:`~PyConfig.site_import` to ``0``.
1460+
* Set :c:member:`~PyConfig.safe_path` to ``1``.
14521461
14531462
The ``__PYVENV_LAUNCHER__`` environment variable is used to set
14541463
:c:member:`PyConfig.base_executable`
@@ -1511,7 +1520,7 @@ initialization, the core feature of :pep:`432`:
15111520
15121521
Private provisional API:
15131522
1514-
* :c:member:`PyConfig._init_main`: if set to 0,
1523+
* :c:member:`PyConfig._init_main`: if set to ``0``,
15151524
:c:func:`Py_InitializeFromConfig` stops at the "Core" initialization phase.
15161525
* :c:member:`PyConfig._isolated_interpreter`: if non-zero,
15171526
disallow threads, subprocesses and fork.

0 commit comments

Comments
 (0)