summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-01 19:59:35 (GMT)
committerGitHub <noreply@github.com>2020-11-01 19:59:35 (GMT)
commit82458b6cdbae3b849dc11d0d7dc2ab06ef0451c4 (patch)
treef70b3003306fdc3165740eec39eadec9a2e82a9c /Modules
parent1f7dfb277e5b88cddc13e5024766be787a3e9127 (diff)
downloadcpython-82458b6cdbae3b849dc11d0d7dc2ab06ef0451c4.zip
cpython-82458b6cdbae3b849dc11d0d7dc2ab06ef0451c4.tar.gz
cpython-82458b6cdbae3b849dc11d0d7dc2ab06ef0451c4.tar.bz2
bpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)
* Rename _Py_GetLocaleEncoding() to _Py_GetLocaleEncodingObject() * Add _Py_GetLocaleEncoding() which returns a wchar_t* string to share code between _Py_GetLocaleEncodingObject() and config_get_locale_encoding(). * _Py_GetLocaleEncodingObject() now decodes nl_langinfo(CODESET) from the current locale encoding with surrogateescape, rather than using UTF-8.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/textio.c2
-rw-r--r--Modules/_localemodule.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 2078bb3..f08d14e 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1155,7 +1155,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
}
}
if (encoding == NULL && self->encoding == NULL) {
- self->encoding = _Py_GetLocaleEncoding();
+ self->encoding = _Py_GetLocaleEncodingObject();
if (self->encoding == NULL) {
goto error;
}
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 359deb7..7b3597e 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -783,7 +783,7 @@ static PyObject *
_locale__get_locale_encoding_impl(PyObject *module)
/*[clinic end generated code: output=e8e2f6f6f184591a input=513d9961d2f45c76]*/
{
- return _Py_GetLocaleEncoding();
+ return _Py_GetLocaleEncodingObject();
}