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.
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;
}