@@ -1291,10 +1291,17 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
|
1291 | 1291 | int init_legacy_encoding = Py_LegacyWindowsFSEncodingFlag; |
1292 | 1292 | #endif |
1293 | 1293 | _PyCoreConfig save_config = _PyCoreConfig_INIT; |
| 1294 | +char *oldloc = NULL; |
1294 | 1295 | int res = -1; |
1295 | 1296 | |
1296 | | -/* Set LC_CTYPE to the user preferred locale */ |
1297 | | -_Py_SetLocaleFromEnv(LC_CTYPE); |
| 1297 | +oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); |
| 1298 | +if (oldloc == NULL) { |
| 1299 | +pymain->err = _Py_INIT_NO_MEMORY(); |
| 1300 | + goto done; |
| 1301 | + } |
| 1302 | + |
| 1303 | +/* Reconfigure the locale to the default for this process */ |
| 1304 | +_Py_SetLocaleFromEnv(LC_ALL); |
1298 | 1305 | |
1299 | 1306 | int locale_coerced = 0; |
1300 | 1307 | int loops = 0; |
@@ -1385,6 +1392,10 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
|
1385 | 1392 | |
1386 | 1393 | done: |
1387 | 1394 | _PyCoreConfig_Clear(&save_config); |
| 1395 | +if (oldloc != NULL) { |
| 1396 | +setlocale(LC_ALL, oldloc); |
| 1397 | +PyMem_RawFree(oldloc); |
| 1398 | + } |
1388 | 1399 | Py_UTF8Mode = init_utf8_mode ; |
1389 | 1400 | #ifdef MS_WINDOWS |
1390 | 1401 | Py_LegacyWindowsFSEncodingFlag = init_legacy_encoding; |
|