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
363363_Py_CoerceLegacyLocale (int warn )
364364{
365365#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+
366373 const char * locale_override = getenv ("LC_ALL" );
367374 if (locale_override == NULL || * locale_override == '\0' ) {
368375 /* LC_ALL is also not set (or is set to an empty string) */
@@ -384,11 +391,16 @@ defined(HAVE_LANGINFO_H) && defined(CODESET)
384391#endif
385392 /* Successfully configured locale, so make it the default */
386393 _coerce_default_locale_settings (warn , target );
387- return ;
394+ goto done ;
388395 }
389396 }
390397 }
391398 /* 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 );
392404#endif
393405}
394406
You can’t perform that action at this time.
0 commit comments