aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/preconfig.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committershadchin <shadchin@yandex-team.com>2024-02-12 08:07:36 +0300
commitce1b7ca3171f9158180640c6a02a74b4afffedea (patch)
treee47c1e8391b1b0128262c1e9b1e6ed4c8fff2348 /contrib/tools/python3/src/Python/preconfig.c
parent57350d96f030db90f220ce50ee591d5c5d403df7 (diff)
downloadydb-ce1b7ca3171f9158180640c6a02a74b4afffedea.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Python/preconfig.c')
-rw-r--r--contrib/tools/python3/src/Python/preconfig.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/contrib/tools/python3/src/Python/preconfig.c b/contrib/tools/python3/src/Python/preconfig.c
index 0deb07a893..77a86d651e 100644
--- a/contrib/tools/python3/src/Python/preconfig.c
+++ b/contrib/tools/python3/src/Python/preconfig.c
@@ -24,6 +24,8 @@ int _Py_HasFileSystemDefaultEncodeErrors = 0;
void
_Py_ClearFileSystemEncoding(void)
{
+_Py_COMP_DIAG_PUSH
+_Py_COMP_DIAG_IGNORE_DEPR_DECLS
if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) {
PyMem_RawFree((char*)Py_FileSystemDefaultEncoding);
Py_FileSystemDefaultEncoding = NULL;
@@ -32,6 +34,7 @@ _Py_ClearFileSystemEncoding(void)
PyMem_RawFree((char*)Py_FileSystemDefaultEncodeErrors);
Py_FileSystemDefaultEncodeErrors = NULL;
}
+_Py_COMP_DIAG_POP
}
@@ -56,11 +59,14 @@ _Py_SetFileSystemEncoding(const char *encoding, const char *errors)
_Py_ClearFileSystemEncoding();
+_Py_COMP_DIAG_PUSH
+_Py_COMP_DIAG_IGNORE_DEPR_DECLS
Py_FileSystemDefaultEncoding = encoding2;
Py_HasFileSystemDefaultEncoding = 0;
Py_FileSystemDefaultEncodeErrors = errors2;
_Py_HasFileSystemDefaultEncodeErrors = 0;
+_Py_COMP_DIAG_POP
return 0;
}
@@ -472,6 +478,8 @@ preconfig_get_global_vars(PyPreConfig *config)
config->ATTR = !(VALUE); \
}
+_Py_COMP_DIAG_PUSH
+_Py_COMP_DIAG_IGNORE_DEPR_DECLS
COPY_FLAG(isolated, Py_IsolatedFlag);
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
if (Py_UTF8Mode > 0) {
@@ -480,6 +488,7 @@ preconfig_get_global_vars(PyPreConfig *config)
#ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
#endif
+_Py_COMP_DIAG_POP
#undef COPY_FLAG
#undef COPY_NOT_FLAG
@@ -498,12 +507,15 @@ preconfig_set_global_vars(const PyPreConfig *config)
VAR = !config->ATTR; \
}
+_Py_COMP_DIAG_PUSH
+_Py_COMP_DIAG_IGNORE_DEPR_DECLS
COPY_FLAG(isolated, Py_IsolatedFlag);
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
#ifdef MS_WINDOWS
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
#endif
COPY_FLAG(utf8_mode, Py_UTF8Mode);
+_Py_COMP_DIAG_POP
#undef COPY_FLAG
#undef COPY_NOT_FLAG
@@ -816,12 +828,10 @@ _PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args)
_Py_SetLocaleFromEnv(LC_CTYPE);
}
- _PyPreCmdline cmdline = _PyPreCmdline_INIT;
- int init_utf8_mode = Py_UTF8Mode;
-#ifdef MS_WINDOWS
- int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag;
-#endif
+ PyPreConfig save_runtime_config;
+ preconfig_copy(&save_runtime_config, &_PyRuntime.preconfig);
+ _PyPreCmdline cmdline = _PyPreCmdline_INIT;
int locale_coerced = 0;
int loops = 0;
@@ -837,11 +847,9 @@ _PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args)
}
/* bpo-34207: Py_DecodeLocale() and Py_EncodeLocale() depend
- on Py_UTF8Mode and Py_LegacyWindowsFSEncodingFlag. */
- Py_UTF8Mode = config->utf8_mode;
-#ifdef MS_WINDOWS
- Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding;
-#endif
+ on the utf8_mode and legacy_windows_fs_encoding members
+ of _PyRuntime.preconfig. */
+ preconfig_copy(&_PyRuntime.preconfig, config);
if (args) {
// Set command line arguments at each iteration. If they are bytes
@@ -904,14 +912,10 @@ _PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args)
status = _PyStatus_OK();
done:
- if (init_ctype_locale != NULL) {
- setlocale(LC_CTYPE, init_ctype_locale);
- PyMem_RawFree(init_ctype_locale);
- }
- Py_UTF8Mode = init_utf8_mode ;
-#ifdef MS_WINDOWS
- Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding;
-#endif
+ // Revert side effects
+ setlocale(LC_CTYPE, init_ctype_locale);
+ PyMem_RawFree(init_ctype_locale);
+ preconfig_copy(&_PyRuntime.preconfig, &save_runtime_config);
_PyPreCmdline_Clear(&cmdline);
return status;
}