| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 86082c2 commit 74f6568
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,18 @@ typedef struct { | |||
| 46 | 46 | #define _Py_INIT_FAILED(err) \ | |
| 47 | 47 | (err.msg != NULL || err.exitcode != -1) | |
| 48 | 48 | ||
| 49 | + /* --- _PyWstrList ------------------------------------------------ */ | ||
| 50 | + | ||
| 51 | + typedef struct { | ||
| 52 | + /* If length is greater than zero, items must be non-NULL | ||
| 53 | + and all items strings must be non-NULL */ | ||
| 54 | + Py_ssize_t length; | ||
| 55 | + wchar_t **items; | ||
| 56 | + } _PyWstrList; | ||
| 57 | + | ||
| 58 | + #define _PyWstrList_INIT (_PyWstrList){.length = 0, .items = NULL} | ||
| 59 | + | ||
| 60 | + | ||
| 49 | 61 | /* --- _PyPreConfig ----------------------------------------------- */ | |
| 50 | 62 | ||
| 51 | 63 | typedef struct { | |
@@ -162,29 +174,24 @@ typedef struct { | |||
| 162 | 174 | char *filesystem_encoding; | |
| 163 | 175 | char *filesystem_errors; | |
| 164 | 176 | ||
| 165 | - wchar_t *pycache_prefix; /* PYTHONPYCACHEPREFIX, -X pycache_prefix=PATH */ | ||
| 166 | - | ||
| 167 | - wchar_t *program_name; /* Program name, see also Py_GetProgramName() */ | ||
| 168 | - int argc; /* Number of command line arguments, | ||
| 169 | - -1 means unset */ | ||
| 170 | - wchar_t **argv; /* Command line arguments */ | ||
| 171 | - wchar_t *program; /* argv[0] or "" */ | ||
| 172 | - | ||
| 173 | - int nxoption; /* Number of -X options */ | ||
| 174 | - wchar_t **xoptions; /* -X options */ | ||
| 175 | - | ||
| 176 | - int nwarnoption; /* Number of warnings options */ | ||
| 177 | - wchar_t **warnoptions; /* Warnings options */ | ||
| 177 | + wchar_t *pycache_prefix; /* PYTHONPYCACHEPREFIX, -X pycache_prefix=PATH */ | ||
| 178 | + wchar_t *program_name; /* Program name, see also Py_GetProgramName() */ | ||
| 179 | + _PyWstrList argv; /* Command line arguments */ | ||
| 180 | + wchar_t *program; /* argv[0] or "" */ | ||
| 181 | + _PyWstrList xoptions; /* Command line -X options */ | ||
| 182 | + _PyWstrList warnoptions; /* Warnings options */ | ||
| 178 | 183 | ||
| 179 | 184 | /* Path configuration inputs */ | |
| 180 | 185 | wchar_t *module_search_path_env; /* PYTHONPATH environment variable */ | |
| 181 | 186 | wchar_t *home; /* PYTHONHOME environment variable, | |
| 182 | 187 | see also Py_SetPythonHome(). */ | |
| 183 | 188 | ||
| 184 | 189 | /* Path configuration outputs */ | |
| 185 | - int nmodule_search_path; /* Number of sys.path paths, | ||
| 186 | - -1 means unset */ | ||
| 187 | - wchar_t **module_search_paths; /* sys.path paths */ | ||
| 190 | + int use_module_search_paths; /* If non-zero, use module_search_paths */ | ||
| 191 | + _PyWstrList module_search_paths; /* sys.path paths. Computed if | ||
| 192 | + use_module_search_paths is equal | ||
| 193 | + to zero. */ | ||
| 194 | + | ||
| 188 | 195 | wchar_t *executable; /* sys.executable */ | |
| 189 | 196 | wchar_t *prefix; /* sys.prefix */ | |
| 190 | 197 | wchar_t *base_prefix; /* sys.base_prefix */ | |
@@ -366,8 +373,7 @@ typedef struct { | |||
| 366 | 373 | .use_hash_seed = -1, \ | |
| 367 | 374 | .faulthandler = -1, \ | |
| 368 | 375 | .tracemalloc = -1, \ | |
| 369 | - .argc = -1, \ | ||
| 370 | - .nmodule_search_path = -1, \ | ||
| 376 | + .use_module_search_paths = 0, \ | ||
| 371 | 377 | .site_import = -1, \ | |
| 372 | 378 | .bytes_warning = -1, \ | |
| 373 | 379 | .inspect = -1, \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,39 +8,38 @@ extern "C" { | |||
| 8 | 8 | # error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined" | |
| 9 | 9 | #endif | |
| 10 | 10 | ||
| 11 | - /* --- _Py_wstrlist ----------------------------------------------- */ | ||
| 12 | - | ||
| 13 | - PyAPI_FUNC(void) _Py_wstrlist_clear( | ||
| 14 | - int len, | ||
| 15 | - wchar_t **list); | ||
| 16 | - PyAPI_FUNC(wchar_t**) _Py_wstrlist_copy( | ||
| 17 | - int len, | ||
| 18 | - wchar_t * const *list); | ||
| 19 | - PyAPI_FUNC(_PyInitError) _Py_wstrlist_append( | ||
| 20 | - int *len, | ||
| 21 | - wchar_t ***list, | ||
| 22 | - const wchar_t *str); | ||
| 23 | - PyAPI_FUNC(PyObject*) _Py_wstrlist_as_pylist( | ||
| 24 | - int len, | ||
| 25 | - wchar_t **list); | ||
| 11 | + | ||
| 12 | + /* --- _PyWstrList ------------------------------------------------ */ | ||
| 13 | + | ||
| 14 | + #ifndef NDEBUG | ||
| 15 | + PyAPI_FUNC(int) _PyWstrList_CheckConsistency(const _PyWstrList *list); | ||
| 16 | + #endif | ||
| 17 | + PyAPI_FUNC(void) _PyWstrList_Clear(_PyWstrList *list); | ||
| 18 | + PyAPI_FUNC(int) _PyWstrList_Copy(_PyWstrList *list, | ||
| 19 | + const _PyWstrList *list2); | ||
| 20 | + PyAPI_FUNC(int) _PyWstrList_Append(_PyWstrList *list, | ||
| 21 | + const wchar_t *item); | ||
| 22 | + PyAPI_FUNC(PyObject*) _PyWstrList_AsList(const _PyWstrList *list); | ||
| 23 | + | ||
| 26 | 24 | ||
| 27 | 25 | /* --- _PyArgv ---------------------------------------------------- */ | |
| 28 | 26 | ||
| 29 | - PyAPI_FUNC(_PyInitError) _PyArgv_Decode(const _PyArgv *args, | ||
| 30 | - wchar_t*** argv_p); | ||
| 27 | + PyAPI_FUNC(_PyInitError) _PyArgv_AsWstrList(const _PyArgv *args, | ||
| 28 | + _PyWstrList *list); | ||
| 29 | + | ||
| 31 | 30 | ||
| 32 | 31 | /* --- Py_GetArgcArgv() helpers ----------------------------------- */ | |
| 33 | 32 | ||
| 34 | 33 | PyAPI_FUNC(void) _Py_ClearArgcArgv(void); | |
| 35 | 34 | ||
| 35 | + | ||
| 36 | 36 | /* --- _PyPreConfig ----------------------------------------------- */ | |
| 37 | 37 | ||
| 38 | 38 | PyAPI_FUNC(int) _Py_str_to_int( | |
| 39 | 39 | const char *str, | |
| 40 | 40 | int *result); | |
| 41 | 41 | PyAPI_FUNC(const wchar_t*) _Py_get_xoption( | |
| 42 | - int nxoption, | ||
| 43 | - wchar_t * const *xoptions, | ||
| 42 | + const _PyWstrList *xoptions, | ||
| 44 | 43 | const wchar_t *name); | |
| 45 | 44 | ||
| 46 | 45 | PyAPI_FUNC(void) _PyPreConfig_Clear(_PyPreConfig *config); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,8 +6,8 @@ | |||
| 6 | 6 | #endif | |
| 7 | 7 | ||
| 8 | 8 | extern int _PyOS_opterr; | |
| 9 | - extern int _PyOS_optind; | ||
| 10 | - extern wchar_t *_PyOS_optarg; | ||
| 9 | + extern Py_ssize_t _PyOS_optind; | ||
| 10 | + extern const wchar_t *_PyOS_optarg; | ||
| 11 | 11 | ||
| 12 | 12 | extern void _PyOS_ResetGetOpt(void); | |
| 13 | 13 | ||
@@ -17,6 +17,6 @@ typedef struct { | |||
| 17 | 17 | int val; | |
| 18 | 18 | } _PyOS_LongOption; | |
| 19 | 19 | ||
| 20 | - extern int _PyOS_GetOpt(int argc, wchar_t **argv, int *longindex); | ||
| 20 | + extern int _PyOS_GetOpt(Py_ssize_t argc, wchar_t **argv, int *longindex); | ||
| 21 | 21 | ||
| 22 | 22 | #endif /* !Py_INTERNAL_PYGETOPT_H */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ PyAPI_FUNC(_PyInitError) _PyPathConfig_SetGlobal( | |||
| 44 | 44 | PyAPI_FUNC(_PyInitError) _PyPathConfig_Calculate_impl( | |
| 45 | 45 | _PyPathConfig *config, | |
| 46 | 46 | const _PyCoreConfig *core_config); | |
| 47 | - PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv); | ||
| 47 | + PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(const _PyWstrList *argv); | ||
| 48 | 48 | PyAPI_FUNC(int) _Py_FindEnvConfigValue( | |
| 49 | 49 | FILE *env_file, | |
| 50 | 50 | const wchar_t *key, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,15 +84,15 @@ mainconfig_add_xoption(PyObject *opts, const wchar_t *s) | |||
| 84 | 84 | static PyObject* | |
| 85 | 85 | mainconfig_create_xoptions_dict(const _PyCoreConfig *config) | |
| 86 | 86 | { | |
| 87 | - int nxoption = config->nxoption; | ||
| 88 | - wchar_t **xoptions = config->xoptions; | ||
| 87 | + Py_ssize_t nxoption = config->xoptions.length; | ||
| 88 | + wchar_t * const * xoptions = config->xoptions.items; | ||
| 89 | 89 | PyObject *dict = PyDict_New(); | |
| 90 | 90 | if (dict == NULL) { | |
| 91 | 91 | return NULL; | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | - for (int i=0; i < nxoption; i++) { | ||
| 95 | - wchar_t *option = xoptions[i]; | ||
| 94 | + for (Py_ssize_t i=0; i < nxoption; i++) { | ||
| 95 | + const wchar_t *option = xoptions[i]; | ||
| 96 | 96 | if (mainconfig_add_xoption(dict, option) < 0) { | |
| 97 | 97 | Py_DECREF(dict); | |
| 98 | 98 | return NULL; | |
@@ -243,22 +243,18 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config, | |||
| 243 | 243 | } \ | |
| 244 | 244 | } \ | |
| 245 | 245 | } while (0) | |
| 246 | - #define COPY_WSTRLIST(ATTR, LEN, LIST) \ | ||
| 246 | + #define COPY_WSTRLIST(ATTR, LIST) \ | ||
| 247 | 247 | do { \ | |
| 248 | 248 | if (ATTR == NULL) { \ | |
| 249 | - ATTR = _Py_wstrlist_as_pylist(LEN, LIST); \ | ||
| 249 | + ATTR = _PyWstrList_AsList(LIST); \ | ||
| 250 | 250 | if (ATTR == NULL) { \ | |
| 251 | 251 | return _Py_INIT_NO_MEMORY(); \ | |
| 252 | 252 | } \ | |
| 253 | 253 | } \ | |
| 254 | 254 | } while (0) | |
| 255 | 255 | ||
| 256 | - COPY_WSTRLIST(main_config->warnoptions, | ||
| 257 | - config->nwarnoption, config->warnoptions); | ||
| 258 | - if (config->argc >= 0) { | ||
| 259 | - COPY_WSTRLIST(main_config->argv, | ||
| 260 | - config->argc, config->argv); | ||
| 261 | - } | ||
| 256 | + COPY_WSTRLIST(main_config->warnoptions, &config->warnoptions); | ||
| 257 | + COPY_WSTRLIST(main_config->argv, &config->argv); | ||
| 262 | 258 | ||
| 263 | 259 | if (config->_install_importlib) { | |
| 264 | 260 | COPY_WSTR(executable); | |
@@ -268,7 +264,7 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config, | |||
| 268 | 264 | COPY_WSTR(base_exec_prefix); | |
| 269 | 265 | ||
| 270 | 266 | COPY_WSTRLIST(main_config->module_search_path, | |
| 271 | - config->nmodule_search_path, config->module_search_paths); | ||
| 267 | + &config->module_search_paths); | ||
| 272 | 268 | ||
| 273 | 269 | if (config->pycache_prefix != NULL) { | |
| 274 | 270 | COPY_WSTR(pycache_prefix); | |
@@ -784,8 +780,7 @@ pymain_run_python(PyInterpreterState *interp, int *exitcode) | |||
| 784 | 780 | } | |
| 785 | 781 | } | |
| 786 | 782 | else if (!config->preconfig.isolated) { | |
| 787 | - PyObject *path0 = _PyPathConfig_ComputeArgv0(config->argc, | ||
| 788 | - config->argv); | ||
| 783 | + PyObject *path0 = _PyPathConfig_ComputeArgv0(&config->argv); | ||
| 789 | 784 | if (path0 == NULL) { | |
| 790 | 785 | err = _Py_INIT_NO_MEMORY(); | |
| 791 | 786 | goto done; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -479,8 +479,8 @@ static int test_init_from_config(void) | |||
| 479 | 479 | L"-c", | |
| 480 | 480 | L"pass", | |
| 481 | 481 | }; | |
| 482 | - config.argc = Py_ARRAY_LENGTH(argv); | ||
| 483 | - config.argv = argv; | ||
| 482 | + config.argv.length = Py_ARRAY_LENGTH(argv); | ||
| 483 | + config.argv.items = argv; | ||
| 484 | 484 | ||
| 485 | 485 | config.program = L"conf_program"; | |
| 486 | 486 | ||
@@ -489,15 +489,15 @@ static int test_init_from_config(void) | |||
| 489 | 489 | L"core_xoption2=", | |
| 490 | 490 | L"core_xoption3", | |
| 491 | 491 | }; | |
| 492 | - config.nxoption = Py_ARRAY_LENGTH(xoptions); | ||
| 493 | - config.xoptions = xoptions; | ||
| 492 | + config.xoptions.length = Py_ARRAY_LENGTH(xoptions); | ||
| 493 | + config.xoptions.items = xoptions; | ||
| 494 | 494 | ||
| 495 | 495 | static wchar_t* warnoptions[2] = { | |
| 496 | 496 | L"default", | |
| 497 | 497 | L"error::ResourceWarning", | |
| 498 | 498 | }; | |
| 499 | - config.nwarnoption = Py_ARRAY_LENGTH(warnoptions); | ||
| 500 | - config.warnoptions = warnoptions; | ||
| 499 | + config.warnoptions.length = Py_ARRAY_LENGTH(warnoptions); | ||
| 500 | + config.warnoptions.items = warnoptions; | ||
| 501 | 501 | ||
| 502 | 502 | /* FIXME: test module_search_path_env */ | |
| 503 | 503 | /* FIXME: test home */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments