summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/coreconfig.c16
-rw-r--r--Python/fileutils.c2
2 files changed, 13 insertions, 5 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index 1b9e26e50a..acf46451f1 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1,5 +1,6 @@
#include "Python.h"
#include "internal/pystate.h"
+#include <locale.h>
#define DECODE_LOCALE_ERR(NAME, LEN) \
@@ -828,14 +829,21 @@ static void
config_init_locale(_PyCoreConfig *config)
{
if (_Py_LegacyLocaleDetected()) {
- /* POSIX locale: enable C locale coercion and UTF-8 Mode */
- if (config->utf8_mode < 0) {
- config->utf8_mode = 1;
- }
+ /* The C locale enables the C locale coercion (PEP 538) */
if (config->coerce_c_locale < 0) {
config->coerce_c_locale = 1;
}
}
+#ifndef MS_WINDOWS
+ const char *ctype_loc = setlocale(LC_CTYPE, NULL);
+ if (ctype_loc != NULL
+ && (strcmp(ctype_loc, "C") == 0 || strcmp(ctype_loc, "POSIX") == 0)) {
+ /* The C locale and the POSIX locale enable the UTF-8 Mode (PEP 540) */
+ if (config->utf8_mode < 0) {
+ config->utf8_mode = 1;
+ }
+ }
+#endif
}
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 35869c81ac..b413f4e1e6 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -128,7 +128,7 @@ check_force_ascii(void)
loc = setlocale(LC_CTYPE, NULL);
if (loc == NULL)
goto error;
- if (strcmp(loc, "C") != 0) {
+ if (strcmp(loc, "C") != 0 && strcmp(loc, "POSIX") != 0) {
/* the LC_CTYPE locale is different than C */
return 0;
}