Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ void
_Py_CoerceLegacyLocale(int warn)
{
#ifdef PY_COERCE_C_LOCALE
char *oldloc = NULL;

oldloc = _PyMem_RawStrdup(setlocale(LC_CTYPE, NULL));
if (oldloc == NULL) {
return;
}

const char *locale_override = getenv("LC_ALL");
if (locale_override == NULL || *locale_override == '\0') {
/* LC_ALL is also not set (or is set to an empty string) */
Expand All @@ -384,11 +391,16 @@ defined(HAVE_LANGINFO_H) && defined(CODESET)
#endif
/* Successfully configured locale, so make it the default */
_coerce_default_locale_settings(warn, target);
return;
goto done;
}
}
}
/* No C locale warning here, as Py_Initialize will emit one later */

setlocale(LC_CTYPE, oldloc);

done:
PyMem_RawFree(oldloc);
#endif
}

Expand Down