| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,7 +94,7 @@ PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); | |||
| 94 | 94 | PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); | |
| 95 | 95 | PyAPI_FUNC(wchar_t *) Py_GetPath(void); | |
| 96 | 96 | #ifdef Py_BUILD_CORE | |
| 97 | - PyAPI_FUNC(wchar_t *) _Py_GetPathWithConfig(_PyCoreConfig *config); | ||
| 97 | + PyAPI_FUNC(wchar_t *) _Py_GetPathWithConfig(_PyMainInterpreterConfig *config); | ||
| 98 | 98 | #endif | |
| 99 | 99 | PyAPI_FUNC(void) Py_SetPath(const wchar_t *); | |
| 100 | 100 | #ifdef MS_WINDOWS | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ typedef struct { | |||
| 30 | 30 | unsigned long hash_seed; | |
| 31 | 31 | int _disable_importlib; /* Needed by freeze_importlib */ | |
| 32 | 32 | const char *allocator; /* Memory allocator: _PyMem_SetupAllocators() */ | |
| 33 | - wchar_t *module_search_path_env; /* PYTHONPATH environment variable */ | ||
| 34 | 33 | int dev_mode; /* -X dev */ | |
| 35 | 34 | int faulthandler; /* -X faulthandler */ | |
| 36 | 35 | int tracemalloc; /* -X tracemalloc=N */ | |
@@ -46,7 +45,6 @@ typedef struct { | |||
| 46 | 45 | .hash_seed = 0, \ | |
| 47 | 46 | ._disable_importlib = 0, \ | |
| 48 | 47 | .allocator = NULL, \ | |
| 49 | - .module_search_path_env = NULL, \ | ||
| 50 | 48 | .dev_mode = 0, \ | |
| 51 | 49 | .faulthandler = 0, \ | |
| 52 | 50 | .tracemalloc = 0, \ | |
@@ -62,11 +60,13 @@ typedef struct { | |||
| 62 | 60 | */ | |
| 63 | 61 | typedef struct { | |
| 64 | 62 | int install_signal_handlers; | |
| 63 | + wchar_t *module_search_path_env; /* PYTHONPATH environment variable */ | ||
| 65 | 64 | } _PyMainInterpreterConfig; | |
| 66 | 65 | ||
| 67 | 66 | #define _PyMainInterpreterConfig_INIT \ | |
| 68 | 67 | (_PyMainInterpreterConfig){\ | |
| 69 | - .install_signal_handlers = -1} | ||
| 68 | + .install_signal_handlers = -1, \ | ||
| 69 | + .module_search_path_env = NULL} | ||
| 70 | 70 | ||
| 71 | 71 | typedef struct _is { | |
| 72 | 72 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -456,7 +456,7 @@ search_for_exec_prefix(wchar_t *argv0_path, wchar_t *home, | |||
| 456 | 456 | } | |
| 457 | 457 | ||
| 458 | 458 | static void | |
| 459 | - calculate_path(_PyCoreConfig *core_config) | ||
| 459 | + calculate_path(_PyMainInterpreterConfig *config) | ||
| 460 | 460 | { | |
| 461 | 461 | extern wchar_t *Py_GetProgramName(void); | |
| 462 | 462 | ||
@@ -706,9 +706,9 @@ calculate_path(_PyCoreConfig *core_config) | |||
| 706 | 706 | bufsz = 0; | |
| 707 | 707 | ||
| 708 | 708 | wchar_t *env_path = NULL; | |
| 709 | - if (core_config) { | ||
| 710 | - if (core_config->module_search_path_env) { | ||
| 711 | - bufsz += wcslen(core_config->module_search_path_env) + 1; | ||
| 709 | + if (config) { | ||
| 710 | + if (config->module_search_path_env) { | ||
| 711 | + bufsz += wcslen(config->module_search_path_env) + 1; | ||
| 712 | 712 | } | |
| 713 | 713 | } | |
| 714 | 714 | else { | |
@@ -752,9 +752,9 @@ calculate_path(_PyCoreConfig *core_config) | |||
| 752 | 752 | ||
| 753 | 753 | /* Run-time value of $PYTHONPATH goes first */ | |
| 754 | 754 | buf[0] = '\0'; | |
| 755 | - if (core_config) { | ||
| 756 | - if (core_config->module_search_path_env) { | ||
| 757 | - wcscpy(buf, core_config->module_search_path_env); | ||
| 755 | + if (config) { | ||
| 756 | + if (config->module_search_path_env) { | ||
| 757 | + wcscpy(buf, config->module_search_path_env); | ||
| 758 | 758 | wcscat(buf, delimiter); | |
| 759 | 759 | } | |
| 760 | 760 | } | |
@@ -858,10 +858,10 @@ Py_SetPath(const wchar_t *path) | |||
| 858 | 858 | } | |
| 859 | 859 | ||
| 860 | 860 | wchar_t * | |
| 861 | - _Py_GetPathWithConfig(_PyCoreConfig *core_config) | ||
| 861 | + _Py_GetPathWithConfig(_PyMainInterpreterConfig *config) | ||
| 862 | 862 | { | |
| 863 | 863 | if (!module_search_path) { | |
| 864 | - calculate_path(core_config); | ||
| 864 | + calculate_path(config); | ||
| 865 | 865 | } | |
| 866 | 866 | return module_search_path; | |
| 867 | 867 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -624,7 +624,7 @@ read_pth_file(const wchar_t *path, wchar_t *prefix, int *isolated, int *nosite) | |||
| 624 | 624 | ||
| 625 | 625 | ||
| 626 | 626 | static void | |
| 627 | - calculate_path(_PyCoreConfig *core_config) | ||
| 627 | + calculate_path(_PyMainInterpreterConfig *config) | ||
| 628 | 628 | { | |
| 629 | 629 | wchar_t argv0_path[MAXPATHLEN+1]; | |
| 630 | 630 | wchar_t *buf; | |
@@ -637,8 +637,8 @@ calculate_path(_PyCoreConfig *core_config) | |||
| 637 | 637 | wchar_t *userpath = NULL; | |
| 638 | 638 | wchar_t zip_path[MAXPATHLEN+1]; | |
| 639 | 639 | ||
| 640 | - if (core_config) { | ||
| 641 | - envpath = core_config->module_search_path_env; | ||
| 640 | + if (config) { | ||
| 641 | + envpath = config->module_search_path_env; | ||
| 642 | 642 | } | |
| 643 | 643 | else if (!Py_IgnoreEnvironmentFlag) { | |
| 644 | 644 | envpath = _wgetenv(L"PYTHONPATH"); | |
@@ -899,10 +899,10 @@ Py_SetPath(const wchar_t *path) | |||
| 899 | 899 | } | |
| 900 | 900 | ||
| 901 | 901 | wchar_t * | |
| 902 | - _Py_GetPathWithConfig(_PyCoreConfig *core_config) | ||
| 902 | + _Py_GetPathWithConfig(_PyMainInterpreterConfig *config) | ||
| 903 | 903 | { | |
| 904 | 904 | if (!module_search_path) { | |
| 905 | - calculate_path(core_config); | ||
| 905 | + calculate_path(config); | ||
| 906 | 906 | } | |
| 907 | 907 | return module_search_path; | |
| 908 | 908 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -843,7 +843,7 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config) | |||
| 843 | 843 | /* GetPath may initialize state that _PySys_EndInit locks | |
| 844 | 844 | in, and so has to be called first. */ | |
| 845 | 845 | /* TODO: Call Py_GetPath() in Py_ReadConfig, rather than here */ | |
| 846 | - wchar_t *sys_path = _Py_GetPathWithConfig(&interp->core_config); | ||
| 846 | + wchar_t *sys_path = _Py_GetPathWithConfig(&interp->config); | ||
| 847 | 847 | ||
| 848 | 848 | if (interp->core_config._disable_importlib) { | |
| 849 | 849 | /* Special mode for freeze_importlib: run with no import system | |
@@ -1301,7 +1301,7 @@ new_interpreter(PyThreadState **tstate_p) | |||
| 1301 | 1301 | ||
| 1302 | 1302 | /* XXX The following is lax in error checking */ | |
| 1303 | 1303 | ||
| 1304 | - wchar_t *sys_path = _Py_GetPathWithConfig(&interp->core_config); | ||
| 1304 | + wchar_t *sys_path = _Py_GetPathWithConfig(&interp->config); | ||
| 1305 | 1305 | ||
| 1306 | 1306 | PyObject *modules = PyDict_New(); | |
| 1307 | 1307 | if (modules == NULL) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments