From 13d5ce08ec5a3ae159bbd7847337d0c52453093d Mon Sep 17 00:00:00 2001 From: shadchin Date: Thu, 20 Jun 2024 22:38:00 +0300 Subject: Enable UTF-8 mode for all 0003a9ac951e380a13106a8f180014e0aed57f3a --- library/python/runtime_py3/main/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'library/python/runtime_py3') diff --git a/library/python/runtime_py3/main/main.c b/library/python/runtime_py3/main/main.c index 896ab0b21d0..0c4aa230138 100644 --- a/library/python/runtime_py3/main/main.c +++ b/library/python/runtime_py3/main/main.c @@ -75,11 +75,26 @@ static int RunModule(const char* modname) } static int pymain(int argc, char** argv) { + PyStatus status; + if (IsYaIdeVenv()) { return Py_BytesMain(argc, argv); } - PyStatus status = _PyRuntime_Initialize(); + status = _PyRuntime_Initialize(); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + + PyPreConfig preconfig; + PyPreConfig_InitPythonConfig(&preconfig); + // Enable UTF-8 mode for all (DEVTOOLSSUPPORT-46624) + preconfig.utf8_mode = 1; +#ifdef MS_WINDOWS + preconfig.legacy_windows_fs_encoding = 0; +#endif + + status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } -- cgit v1.3