bpo-32030: Move PYTHONPATH to _PyMainInterpreterConfig (#4511) · python/cpython@e32e79f (original) (raw)
`@@ -389,6 +389,7 @@ typedef struct {
`
389
389
`/* non-zero is stdin is a TTY or if -i option is used */
`
390
390
`int stdin_is_interactive;
`
391
391
`_PyCoreConfig core_config;
`
``
392
`+
_PyMainInterpreterConfig config;
`
392
393
`_Py_CommandLineDetails cmdline;
`
393
394
`PyObject *main_importer_path;
`
394
395
`/* non-zero if filename, command (-c) or module (-m) is set
`
`@@ -409,6 +410,7 @@ typedef struct {
`
409
410
` {.status = 0, \
`
410
411
` .cf = {.cf_flags = 0}, \
`
411
412
` .core_config = _PyCoreConfig_INIT, \
`
``
413
`+
.config = _PyMainInterpreterConfig_INIT, \
`
412
414
` .main_importer_path = NULL, \
`
413
415
` .run_code = -1, \
`
414
416
` .program_name = NULL, \
`
`@@ -442,7 +444,7 @@ pymain_free_impl(_PyMain *pymain)
`
442
444
`Py_CLEAR(pymain->main_importer_path);
`
443
445
`PyMem_RawFree(pymain->program_name);
`
444
446
``
445
``
`-
PyMem_RawFree(pymain->core_config.module_search_path_env);
`
``
447
`+
PyMem_RawFree(pymain->config.module_search_path_env);
`
446
448
``
447
449
`#ifdef INSURE
`
448
450
`/* Insure++ is a memory analysis tool that aids in discovering
`
`@@ -957,20 +959,16 @@ pymain_get_program_name(_PyMain *pymain)
`
957
959
`static int
`
958
960
`pymain_init_main_interpreter(_PyMain *pymain)
`
959
961
`{
`
960
``
`-
_PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
`
961
962
`_PyInitError err;
`
962
963
``
963
``
`-
/* TODO: Moar config options! */
`
964
``
`-
config.install_signal_handlers = 1;
`
965
``
-
966
964
`/* TODO: Print any exceptions raised by these operations */
`
967
``
`-
err = _Py_ReadMainInterpreterConfig(&config);
`
``
965
`+
err = _Py_ReadMainInterpreterConfig(&pymain->config);
`
968
966
`if (_Py_INIT_FAILED(err)) {
`
969
967
`pymain->err = err;
`
970
968
`return -1;
`
971
969
` }
`
972
970
``
973
``
`-
err = _Py_InitializeMainInterpreter(&config);
`
``
971
`+
err = _Py_InitializeMainInterpreter(&pymain->config);
`
974
972
`if (_Py_INIT_FAILED(err)) {
`
975
973
`pymain->err = err;
`
976
974
`return -1;
`
`@@ -1387,7 +1385,7 @@ pymain_init_pythonpath(_PyMain *pymain)
`
1387
1385
`return -1;
`
1388
1386
` }
`
1389
1387
``
1390
``
`-
pymain->core_config.module_search_path_env = path2;
`
``
1388
`+
pymain->config.module_search_path_env = path2;
`
1391
1389
`#else
`
1392
1390
`char *path = pymain_get_env_var("PYTHONPATH");
`
1393
1391
`if (!path) {
`
`@@ -1405,7 +1403,7 @@ pymain_init_pythonpath(_PyMain *pymain)
`
1405
1403
` }
`
1406
1404
`return -1;
`
1407
1405
` }
`
1408
``
`-
pymain->core_config.module_search_path_env = wpath;
`
``
1406
`+
pymain->config.module_search_path_env = wpath;
`
1409
1407
`#endif
`
1410
1408
`return 0;
`
1411
1409
`}
`
`@@ -1574,6 +1572,8 @@ pymain_init(_PyMain *pymain)
`
1574
1572
` }
`
1575
1573
``
1576
1574
`pymain->core_config._disable_importlib = 0;
`
``
1575
`+
/* TODO: Moar config options! */
`
``
1576
`+
pymain->config.install_signal_handlers = 1;
`
1577
1577
``
1578
1578
`orig_argc = pymain->argc; /* For Py_GetArgcArgv() */
`
1579
1579
`orig_argv = pymain->argv;
`