summaryrefslogtreecommitdiffstats
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-10-31 00:32:11 (GMT)
committerGitHub <noreply@github.com>2020-10-31 00:32:11 (GMT)
commitb62bdf71ea0cd52041d49691d8ae3dc645bd48e1 (patch)
tree376fe1864673d8de21c8621629765cd1a28cdb1b /Modules/_localemodule.c
parent710e82630775774dceba5e8f24b1b10e6dfaf9b7 (diff)
downloadcpython-b62bdf71ea0cd52041d49691d8ae3dc645bd48e1.zip
cpython-b62bdf71ea0cd52041d49691d8ae3dc645bd48e1.tar.gz
cpython-b62bdf71ea0cd52041d49691d8ae3dc645bd48e1.tar.bz2
bpo-42208: Add _locale._get_locale_encoding() (GH-23052)
* Add a new _locale._get_locale_encoding() function to get the current locale encoding. * Modify locale.getpreferredencoding() to use it. * Remove the _bootlocale module.
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r--Modules/_localemodule.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 9c7ce87..359deb7 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -768,9 +768,24 @@ _locale_bind_textdomain_codeset_impl(PyObject *module, const char *domain,
}
Py_RETURN_NONE;
}
-#endif
+#endif // HAVE_BIND_TEXTDOMAIN_CODESET
+
+#endif // HAVE_LIBINTL_H
+
+
+/*[clinic input]
+_locale._get_locale_encoding
+
+Get the current locale encoding.
+[clinic start generated code]*/
+
+static PyObject *
+_locale__get_locale_encoding_impl(PyObject *module)
+/*[clinic end generated code: output=e8e2f6f6f184591a input=513d9961d2f45c76]*/
+{
+ return _Py_GetLocaleEncoding();
+}
-#endif
static struct PyMethodDef PyLocale_Methods[] = {
_LOCALE_SETLOCALE_METHODDEF
@@ -797,6 +812,7 @@ static struct PyMethodDef PyLocale_Methods[] = {
_LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF
#endif
#endif
+ _LOCALE__GET_LOCALE_ENCODING_METHODDEF
{NULL, NULL}
};