From 22794d45b7a167ed778e74aef14fe2aa3ac8f32a Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Thu, 26 Oct 2017 16:56:21 +0200 Subject: [PATCH 1/2] Add _Py_LegacyLocaleDetected and _PyCoerceLegacyLocale to pylifecycle.h --- Include/pylifecycle.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index e1737b5972b39a..8bbce7fd61dc7c 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -133,6 +133,12 @@ PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size); PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size); #endif /* !Py_LIMITED_API */ +/* Legacy locale support */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_CoerceLegacyLocale(void); +PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void); +#endif + #ifdef __cplusplus } #endif From 06c5b9a1d50dd526d57766c1620a1dd2b25f2676 Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Fri, 27 Oct 2017 10:15:23 +0200 Subject: [PATCH 2/2] Removed no longer necessary private declarations of these functions. Kept the explanatory comment but moved it to the relevant part of the code. --- Programs/python.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Programs/python.c b/Programs/python.c index 03f8295045cfc6..4f6b9198c8504e 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -15,20 +15,6 @@ wmain(int argc, wchar_t **argv) } #else -/* Access private pylifecycle helper API to better handle the legacy C locale - * - * The legacy C locale assumes ASCII as the default text encoding, which - * causes problems not only for the CPython runtime, but also other - * components like GNU readline. - * - * Accordingly, when the CLI detects it, it attempts to coerce it to a - * more capable UTF-8 based alternative. - * - * See the documentation of the PYTHONCOERCECLOCALE setting for more details. - * - */ -extern int _Py_LegacyLocaleDetected(void); -extern void _Py_CoerceLegacyLocale(void); int main(int argc, char **argv) @@ -78,6 +64,16 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); #endif + /* The legacy C locale assumes ASCII as the default text encoding, which + * causes problems not only for the CPython runtime, but also other + * components like GNU readline. + * + * Accordingly, when the CLI detects it, it attempts to coerce it to a + * more capable UTF-8 based alternative. + * + * See the documentation of the PYTHONCOERCECLOCALE setting for more + * details. + */ if (_Py_LegacyLocaleDetected()) { _Py_CoerceLegacyLocale(); }