@@ -132,7 +132,6 @@ typedef struct {
132132
133133static const wchar_t delimiter [2 ] = {DELIM , '\0' };
134134static const wchar_t separator [2 ] = {SEP , '\0' };
135- static _PyPathConfig _Py_path_config = _PyPathConfig_INIT ;
136135
137136
138137/* Get file status. Encode the path to the locale encoding. */
@@ -1009,23 +1008,6 @@ calculate_path_impl(const _PyMainInterpreterConfig *main_config,
10091008}
10101009
10111010
1012- static void
1013- pathconfig_clear (_PyPathConfig * config )
1014- {
1015- #define CLEAR (ATTR ) \
1016- do { \
1017- PyMem_RawFree(ATTR); \
1018- ATTR = NULL; \
1019- } while (0)
1020-
1021- CLEAR (config -> prefix );
1022- CLEAR (config -> exec_prefix );
1023- CLEAR (config -> program_full_path );
1024- CLEAR (config -> module_search_path );
1025- #undef CLEAR
1026- }
1027-
1028-
10291011/* Initialize paths for Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix()
10301012 and Py_GetProgramFullPath() */
10311013_PyInitError
@@ -1049,7 +1031,7 @@ _PyPathConfig_Init(const _PyMainInterpreterConfig *main_config)
10491031
10501032 err = calculate_path_impl (main_config , & calculate , & new_path_config );
10511033 if (_Py_INIT_FAILED (err )) {
1052- pathconfig_clear (& new_path_config );
1034+ _PyPathConfig_Clear (& new_path_config );
10531035 goto done ;
10541036 }
10551037
@@ -1061,100 +1043,6 @@ _PyPathConfig_Init(const _PyMainInterpreterConfig *main_config)
10611043 return err ;
10621044}
10631045
1064-
1065- static void
1066- pathconfig_global_init (void )
1067- {
1068- if (_Py_path_config .module_search_path ) {
1069- /* Already initialized */
1070- return ;
1071- }
1072-
1073- _PyInitError err ;
1074- _PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT ;
1075-
1076- err = _PyMainInterpreterConfig_ReadEnv (& config );
1077- if (_Py_INIT_FAILED (err )) {
1078- goto error ;
1079- }
1080-
1081- err = _PyMainInterpreterConfig_Read (& config );
1082- if (_Py_INIT_FAILED (err )) {
1083- goto error ;
1084- }
1085-
1086- err = _PyPathConfig_Init (& config );
1087- if (_Py_INIT_FAILED (err )) {
1088- goto error ;
1089- }
1090-
1091- _PyMainInterpreterConfig_Clear (& config );
1092- return ;
1093-
1094- error :
1095- _PyMainInterpreterConfig_Clear (& config );
1096- _Py_FatalInitError (err );
1097- }
1098-
1099-
1100- void
1101- _PyPathConfig_Fini (void )
1102- {
1103- pathconfig_clear (& _Py_path_config );
1104- }
1105-
1106-
1107- /* External interface */
1108- void
1109- Py_SetPath (const wchar_t * path )
1110- {
1111- if (path == NULL ) {
1112- pathconfig_clear (& _Py_path_config );
1113- return ;
1114- }
1115-
1116- _PyPathConfig new_config ;
1117- new_config .program_full_path = _PyMem_RawWcsdup (Py_GetProgramName ());
1118- new_config .exec_prefix = _PyMem_RawWcsdup (L"" );
1119- new_config .prefix = _PyMem_RawWcsdup (L"" );
1120- new_config .module_search_path = _PyMem_RawWcsdup (path );
1121-
1122- pathconfig_clear (& _Py_path_config );
1123- _Py_path_config = new_config ;
1124- }
1125-
1126-
1127- wchar_t *
1128- Py_GetPath (void )
1129- {
1130- pathconfig_global_init ();
1131- return _Py_path_config .module_search_path ;
1132- }
1133-
1134-
1135- wchar_t *
1136- Py_GetPrefix (void )
1137- {
1138- pathconfig_global_init ();
1139- return _Py_path_config .prefix ;
1140- }
1141-
1142-
1143- wchar_t *
1144- Py_GetExecPrefix (void )
1145- {
1146- pathconfig_global_init ();
1147- return _Py_path_config .exec_prefix ;
1148- }
1149-
1150-
1151- wchar_t *
1152- Py_GetProgramFullPath (void )
1153- {
1154- pathconfig_global_init ();
1155- return _Py_path_config .program_full_path ;
1156- }
1157-
11581046#ifdef __cplusplus
11591047}
11601048#endif
0 commit comments