Lines Matching +full:- +full:- +full:fail +full:- +full:env +full:- +full:changed
9 (((LEN) == -2) \
19 /* --- File system encoding/errors -------------------------------- */
25 are encoded to UTF-8. */
52 return -1; in _Py_SetFileSystemEncoding()
58 return -1; in _Py_SetFileSystemEncoding()
72 /* --- _PyArgv ---------------------------------------------------- */
79 if (args->use_bytes_argv) { in _PyArgv_AsWstrList()
80 size_t size = sizeof(wchar_t*) * args->argc; in _PyArgv_AsWstrList()
86 for (Py_ssize_t i = 0; i < args->argc; i++) { in _PyArgv_AsWstrList()
88 wchar_t *arg = Py_DecodeLocale(args->bytes_argv[i], &len); in _PyArgv_AsWstrList()
102 wargv.length = args->argc; in _PyArgv_AsWstrList()
103 wargv.items = (wchar_t **)args->wchar_argv; in _PyArgv_AsWstrList()
112 /* --- _PyPreCmdline ------------------------------------------------- */
117 _PyWideStringList_Clear(&cmdline->argv); in _PyPreCmdline_Clear()
118 _PyWideStringList_Clear(&cmdline->xoptions); in _PyPreCmdline_Clear()
125 return _PyArgv_AsWstrList(args, &cmdline->argv); in _PyPreCmdline_SetArgv()
133 if (config->ATTR != -1) { \ in precmdline_get_preconfig()
134 cmdline->ATTR = config->ATTR; \ in precmdline_get_preconfig()
149 config->ATTR = cmdline->ATTR in precmdline_set_preconfig()
163 config->ATTR = cmdline->ATTR in _PyPreCmdline_SetConfig()
165 PyStatus status = _PyWideStringList_Extend(&config->xoptions, &cmdline->xoptions); in _PyPreCmdline_SetConfig()
183 const PyWideStringList *argv = &cmdline->argv; in precmdline_parse_cmdline()
190 int longindex = -1; in precmdline_parse_cmdline()
191 int c = _PyOS_GetOpt(argv->length, argv->items, &longindex); in precmdline_parse_cmdline()
199 cmdline->use_environment = 0; in precmdline_parse_cmdline()
203 cmdline->isolated = 1; in precmdline_parse_cmdline()
208 PyStatus status = PyWideStringList_Append(&cmdline->xoptions, in precmdline_parse_cmdline()
232 if (preconfig->parse_argv) { in _PyPreCmdline_Read()
240 if (cmdline->isolated < 0) { in _PyPreCmdline_Read()
241 cmdline->isolated = 0; in _PyPreCmdline_Read()
243 if (cmdline->isolated > 0) { in _PyPreCmdline_Read()
244 cmdline->use_environment = 0; in _PyPreCmdline_Read()
246 if (cmdline->use_environment < 0) { in _PyPreCmdline_Read()
247 cmdline->use_environment = 0; in _PyPreCmdline_Read()
251 if ((cmdline->dev_mode < 0) in _PyPreCmdline_Read()
252 && (_Py_get_xoption(&cmdline->xoptions, L"dev") in _PyPreCmdline_Read()
253 || _Py_GetEnv(cmdline->use_environment, "PYTHONDEVMODE"))) in _PyPreCmdline_Read()
255 cmdline->dev_mode = 1; in _PyPreCmdline_Read()
257 if (cmdline->dev_mode < 0) { in _PyPreCmdline_Read()
258 cmdline->dev_mode = 0; in _PyPreCmdline_Read()
261 assert(cmdline->use_environment >= 0); in _PyPreCmdline_Read()
262 assert(cmdline->isolated >= 0); in _PyPreCmdline_Read()
263 assert(cmdline->dev_mode >= 0); in _PyPreCmdline_Read()
269 /* --- PyPreConfig ----------------------------------------------- */
277 config->_config_init = (int)_PyConfig_INIT_COMPAT; in _PyPreConfig_InitCompatConfig()
278 config->parse_argv = 0; in _PyPreConfig_InitCompatConfig()
279 config->isolated = -1; in _PyPreConfig_InitCompatConfig()
280 config->use_environment = -1; in _PyPreConfig_InitCompatConfig()
281 config->configure_locale = 1; in _PyPreConfig_InitCompatConfig()
283 /* bpo-36443: C locale coercion (PEP 538) and UTF-8 Mode (PEP 540) in _PyPreConfig_InitCompatConfig()
286 Py_UTF8Mode=1 enables the UTF-8 mode. PYTHONUTF8 environment variable in _PyPreConfig_InitCompatConfig()
288 config->utf8_mode = 0; in _PyPreConfig_InitCompatConfig()
289 config->coerce_c_locale = 0; in _PyPreConfig_InitCompatConfig()
290 config->coerce_c_locale_warn = 0; in _PyPreConfig_InitCompatConfig()
292 config->dev_mode = -1; in _PyPreConfig_InitCompatConfig()
293 config->allocator = PYMEM_ALLOCATOR_NOT_SET; in _PyPreConfig_InitCompatConfig()
295 config->legacy_windows_fs_encoding = -1; in _PyPreConfig_InitCompatConfig()
305 config->_config_init = (int)_PyConfig_INIT_PYTHON; in PyPreConfig_InitPythonConfig()
306 config->isolated = 0; in PyPreConfig_InitPythonConfig()
307 config->parse_argv = 1; in PyPreConfig_InitPythonConfig()
308 config->use_environment = 1; in PyPreConfig_InitPythonConfig()
309 /* Set to -1 to enable C locale coercion (PEP 538) and UTF-8 Mode (PEP 540) in PyPreConfig_InitPythonConfig()
312 config->coerce_c_locale = -1; in PyPreConfig_InitPythonConfig()
313 config->coerce_c_locale_warn = -1; in PyPreConfig_InitPythonConfig()
314 config->utf8_mode = -1; in PyPreConfig_InitPythonConfig()
316 config->legacy_windows_fs_encoding = 0; in PyPreConfig_InitPythonConfig()
326 config->_config_init = (int)_PyConfig_INIT_ISOLATED; in PyPreConfig_InitIsolatedConfig()
327 config->configure_locale = 0; in PyPreConfig_InitIsolatedConfig()
328 config->isolated = 1; in PyPreConfig_InitIsolatedConfig()
329 config->use_environment = 0; in PyPreConfig_InitIsolatedConfig()
330 config->utf8_mode = 0; in PyPreConfig_InitIsolatedConfig()
331 config->dev_mode = 0; in PyPreConfig_InitIsolatedConfig()
333 config->legacy_windows_fs_encoding = 0; in PyPreConfig_InitIsolatedConfig()
351 _PyConfigInitEnum config_init = (_PyConfigInitEnum)config->_config_init; in _PyPreConfig_InitFromConfig()
371 #define COPY_ATTR(ATTR) config->ATTR = config2->ATTR in preconfig_copy()
403 PyObject *obj = PyLong_FromLong(config->ATTR); \ in _PyPreConfig_AsDict()
405 goto fail; \ in _PyPreConfig_AsDict()
410 goto fail; \ in _PyPreConfig_AsDict()
429 fail: in _PyPreConfig_AsDict()
441 if (config->ATTR != -1) { \ in _PyPreConfig_GetConfig()
442 preconfig->ATTR = config->ATTR; \ in _PyPreConfig_GetConfig()
457 if (config->_config_init != _PyConfig_INIT_COMPAT) { in preconfig_get_global_vars()
463 if (config->ATTR < 0) { \ in preconfig_get_global_vars()
464 config->ATTR = VALUE; \ in preconfig_get_global_vars()
467 if (config->ATTR < 0) { \ in preconfig_get_global_vars()
468 config->ATTR = !(VALUE); \ in preconfig_get_global_vars()
474 config->utf8_mode = Py_UTF8Mode; in preconfig_get_global_vars()
489 if (config->ATTR >= 0) { \ in preconfig_set_global_vars()
490 VAR = config->ATTR; \ in preconfig_set_global_vars()
493 if (config->ATTR >= 0) { \ in preconfig_set_global_vars()
494 VAR = !config->ATTR; \ in preconfig_set_global_vars()
535 return -1; in _Py_str_to_int()
538 return -1; in _Py_str_to_int()
555 /* PYTHONDEBUG=text and PYTHONDEBUG=-2 behave as PYTHONDEBUG=1 */ in _Py_get_env_flag()
567 for (Py_ssize_t i=0; i < xoptions->length; i++) { in _Py_get_xoption()
568 const wchar_t *option = xoptions->items[i]; in _Py_get_xoption()
572 len = (sep - option); in _Py_get_xoption()
589 if (config->legacy_windows_fs_encoding) { in preconfig_init_utf8_mode()
590 config->utf8_mode = 0; in preconfig_init_utf8_mode()
594 if (config->utf8_mode >= 0) { in preconfig_init_utf8_mode()
599 xopt = _Py_get_xoption(&cmdline->xoptions, L"utf8"); in preconfig_init_utf8_mode()
605 config->utf8_mode = 1; in preconfig_init_utf8_mode()
608 config->utf8_mode = 0; in preconfig_init_utf8_mode()
611 return _PyStatus_ERR("invalid -X utf8 option value"); in preconfig_init_utf8_mode()
615 config->utf8_mode = 1; in preconfig_init_utf8_mode()
620 const char *opt = _Py_GetEnv(config->use_environment, "PYTHONUTF8"); in preconfig_init_utf8_mode()
623 config->utf8_mode = 1; in preconfig_init_utf8_mode()
626 config->utf8_mode = 0; in preconfig_init_utf8_mode()
637 if (config->utf8_mode < 0) { in preconfig_init_utf8_mode()
638 /* The C locale and the POSIX locale enable the UTF-8 Mode (PEP 540) */ in preconfig_init_utf8_mode()
644 config->utf8_mode = 1; in preconfig_init_utf8_mode()
649 if (config->utf8_mode < 0) { in preconfig_init_utf8_mode()
650 config->utf8_mode = 0; in preconfig_init_utf8_mode()
659 if (!config->configure_locale) { in preconfig_init_coerce_c_locale()
660 config->coerce_c_locale = 0; in preconfig_init_coerce_c_locale()
661 config->coerce_c_locale_warn = 0; in preconfig_init_coerce_c_locale()
665 const char *env = _Py_GetEnv(config->use_environment, "PYTHONCOERCECLOCALE"); in preconfig_init_coerce_c_locale() local
666 if (env) { in preconfig_init_coerce_c_locale()
667 if (strcmp(env, "0") == 0) { in preconfig_init_coerce_c_locale()
668 if (config->coerce_c_locale < 0) { in preconfig_init_coerce_c_locale()
669 config->coerce_c_locale = 0; in preconfig_init_coerce_c_locale()
672 else if (strcmp(env, "warn") == 0) { in preconfig_init_coerce_c_locale()
673 if (config->coerce_c_locale_warn < 0) { in preconfig_init_coerce_c_locale()
674 config->coerce_c_locale_warn = 1; in preconfig_init_coerce_c_locale()
678 if (config->coerce_c_locale < 0) { in preconfig_init_coerce_c_locale()
679 config->coerce_c_locale = 1; in preconfig_init_coerce_c_locale()
684 /* Test if coerce_c_locale equals to -1 or equals to 1: in preconfig_init_coerce_c_locale()
687 if (config->coerce_c_locale < 0 || config->coerce_c_locale == 1) { in preconfig_init_coerce_c_locale()
690 config->coerce_c_locale = 2; in preconfig_init_coerce_c_locale()
693 config->coerce_c_locale = 0; in preconfig_init_coerce_c_locale()
697 if (config->coerce_c_locale_warn < 0) { in preconfig_init_coerce_c_locale()
698 config->coerce_c_locale_warn = 0; in preconfig_init_coerce_c_locale()
706 if (config->allocator == PYMEM_ALLOCATOR_NOT_SET) { in preconfig_init_allocator()
707 /* bpo-34247. The PYTHONMALLOC environment variable has the priority in preconfig_init_allocator()
708 over PYTHONDEV env var and "-X dev" command line option. in preconfig_init_allocator()
711 const char *envvar = _Py_GetEnv(config->use_environment, "PYTHONMALLOC"); in preconfig_init_allocator()
717 config->allocator = (int)name; in preconfig_init_allocator()
721 if (config->dev_mode && config->allocator == PYMEM_ALLOCATOR_NOT_SET) { in preconfig_init_allocator()
722 config->allocator = PYMEM_ALLOCATOR_DEBUG; in preconfig_init_allocator()
742 _Py_get_env_flag(config->use_environment, in preconfig_read()
743 &config->legacy_windows_fs_encoding, in preconfig_read()
760 assert(config->coerce_c_locale >= 0); in preconfig_read()
761 assert(config->coerce_c_locale_warn >= 0); in preconfig_read()
763 assert(config->legacy_windows_fs_encoding >= 0); in preconfig_read()
765 assert(config->utf8_mode >= 0); in preconfig_read()
766 assert(config->isolated >= 0); in preconfig_read()
767 assert(config->use_environment >= 0); in preconfig_read()
768 assert(config->dev_mode >= 0); in preconfig_read()
776 - command line arguments
777 - environment variables
778 - Py_xxx global configuration variables
779 - the LC_CTYPE locale */
811 if (config->configure_locale) { in _PyPreConfig_Read()
832 int utf8_mode = config->utf8_mode; in _PyPreConfig_Read()
837 status = _PyStatus_ERR("Encoding changed twice while " in _PyPreConfig_Read()
842 /* bpo-34207: Py_DecodeLocale() and Py_EncodeLocale() depend in _PyPreConfig_Read()
844 Py_UTF8Mode = config->utf8_mode; in _PyPreConfig_Read()
846 Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding; in _PyPreConfig_Read()
859 * more capable UTF-8 based alternative. in _PyPreConfig_Read()
865 if (config->coerce_c_locale && !locale_coerced) { in _PyPreConfig_Read()
871 if (utf8_mode == -1) { in _PyPreConfig_Read()
872 if (config->utf8_mode == 1) { in _PyPreConfig_Read()
873 /* UTF-8 Mode enabled */ in _PyPreConfig_Read()
878 if (config->utf8_mode != utf8_mode) { in _PyPreConfig_Read()
888 just keep UTF-8 Mode value. */ in _PyPreConfig_Read()
889 int new_utf8_mode = config->utf8_mode; in _PyPreConfig_Read()
890 int new_coerce_c_locale = config->coerce_c_locale; in _PyPreConfig_Read()
892 config->utf8_mode = new_utf8_mode; in _PyPreConfig_Read()
893 config->coerce_c_locale = new_coerce_c_locale; in _PyPreConfig_Read()
895 /* The encoding changed: read again the configuration in _PyPreConfig_Read()
914 /* Write the pre-configuration:
916 - set the memory allocators
917 - set Py_xxx global configuration variables
918 - set the LC_CTYPE locale (coerce C locale, PEP 538) and set the UTF-8 mode
925 pre-configuration. */
937 /* bpo-34008: Calling this functions after Py_Initialize() ignores in _PyPreConfig_Write()
963 /* Write the new pre-configuration into _PyRuntime */ in _PyPreConfig_Write()