File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,13 @@ void
363
363
_Py_CoerceLegacyLocale (int warn )
364
364
{
365
365
#ifdef PY_COERCE_C_LOCALE
366
+ char * oldloc = NULL ;
367
+
368
+ oldloc = _PyMem_RawStrdup (setlocale (LC_CTYPE , NULL ));
369
+ if (oldloc == NULL ) {
370
+ return ;
371
+ }
372
+
366
373
const char * locale_override = getenv ("LC_ALL" );
367
374
if (locale_override == NULL || * locale_override == '\0' ) {
368
375
/* LC_ALL is also not set (or is set to an empty string) */
@@ -384,11 +391,16 @@ defined(HAVE_LANGINFO_H) && defined(CODESET)
384
391
#endif
385
392
/* Successfully configured locale, so make it the default */
386
393
_coerce_default_locale_settings (warn , target );
387
- return ;
394
+ goto done ;
388
395
}
389
396
}
390
397
}
391
398
/* No C locale warning here, as Py_Initialize will emit one later */
399
+
400
+ setlocale (LC_CTYPE , oldloc );
401
+
402
+ done :
403
+ PyMem_RawFree (oldloc );
392
404
#endif
393
405
}
394
406
You can’t perform that action at this time.
0 commit comments