gh-74857, PEP 538: Coerce POSIX locale to UTF-8 based locale (#139238)

This commit is contained in:
Victor Stinner
2025-09-23 19:20:59 +02:00
committed by GitHub
parent a79ce35c70
commit e8382e55c5
3 changed files with 10 additions and 9 deletions

View File

@@ -209,7 +209,10 @@ _Py_LegacyLocaleDetected(int warn)
* we may also want to check for that explicitly.
*/
const char *ctype_loc = setlocale(LC_CTYPE, NULL);
return ctype_loc != NULL && strcmp(ctype_loc, "C") == 0;
if (ctype_loc == NULL) {
return 0;
}
return (strcmp(ctype_loc, "C") == 0 || strcmp(ctype_loc, "POSIX") == 0);
#else
/* Windows uses code pages instead of locales, so no locale is legacy */
return 0;