@@ -1289,7 +1289,11 @@ Example setting the program name::
12891289 }
12901290
12911291 More complete example modifying the default configuration, read the
1292- configuration, and then override some parameters::
1292+ configuration, and then override some parameters. Note that since
1293+ 3.11, many parameters are not calculated until initialization, and
1294+ so values cannot be read from the configuration structure. Any values
1295+ set before initialize is called will be left unchanged by
1296+ initialization::
12931297
12941298 PyStatus init_python(const char *program_name)
12951299 {
@@ -1314,7 +1318,15 @@ configuration, and then override some parameters::
13141318 goto done;
13151319 }
13161320
1317- /* Append our custom search path to sys.path */
1321+ /* Specify sys.path explicitly */
1322+ /* To calculate the default and then modify, finish initialization and
1323+ then use PySys_GetObject("path") to get the list. */
1324+ condig.module_search_paths_set = 1
1325+ status = PyWideStringList_Append(&config.module_search_paths,
1326+ L"/path/to/stdlib");
1327+ if (PyStatus_Exception(status)) {
1328+ goto done;
1329+ }
13181330 status = PyWideStringList_Append(&config.module_search_paths,
13191331 L"/path/to/more/modules");
13201332 if (PyStatus_Exception(status)) {
@@ -1417,8 +1429,8 @@ It is possible to completely ignore the function calculating the default
14171429path configuration by setting explicitly all path configuration output
14181430fields listed above. A string is considered as set even if it is non-empty.
14191431``module_search_paths`` is considered as set if
1420- ``module_search_paths_set`` is set to ``1``. In this case, path
1421- configuration input fields are ignored as well .
1432+ ``module_search_paths_set`` is set to ``1``. In this case,
1433+ ``module_search_paths`` will be used without modification .
14221434
14231435Set :c:member:`~PyConfig.pathconfig_warnings` to ``0`` to suppress warnings when
14241436calculating the path configuration (Unix only, Windows does not log any warning).
0 commit comments