diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-08-28 17:27:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-28 17:27:36 +0200 |
commit | d500e5307aec9c5d535f66d567fadb9c587a9a36 (patch) | |
tree | 37f95130926a65be9419683aca896b3dcfcfceee /Python/coreconfig.c | |
parent | 5cb258950ce9b69b1f65646431c464c0c17b1510 (diff) | |
download | cpython-git-d500e5307aec9c5d535f66d567fadb9c587a9a36.tar.gz |
bpo-34403: On HP-UX, force ASCII for C locale (GH-8969)
On HP-UX with C or POSIX locale, sys.getfilesystemencoding() now returns
"ascii" instead of "roman8" (when the UTF-8 Mode is disabled and the C locale
is not coerced).
nl_langinfo(CODESET) announces "roman8" whereas it uses the Latin1
encoding in practice.
Diffstat (limited to 'Python/coreconfig.c')
-rw-r--r-- | Python/coreconfig.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c index acf46451f1..d08d75b196 100644 --- a/Python/coreconfig.c +++ b/Python/coreconfig.c @@ -828,18 +828,21 @@ config_read_complex_options(_PyCoreConfig *config) static void config_init_locale(_PyCoreConfig *config) { - if (_Py_LegacyLocaleDetected()) { + if (config->coerce_c_locale < 0) { /* The C locale enables the C locale coercion (PEP 538) */ - if (config->coerce_c_locale < 0) { + if (_Py_LegacyLocaleDetected()) { 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)) { + if (config->utf8_mode < 0) { /* The C locale and the POSIX locale enable the UTF-8 Mode (PEP 540) */ - if (config->utf8_mode < 0) { + const char *ctype_loc = setlocale(LC_CTYPE, NULL); + if (ctype_loc != NULL + && (strcmp(ctype_loc, "C") == 0 + || strcmp(ctype_loc, "POSIX") == 0)) + { config->utf8_mode = 1; } } |