]> granicus.if.org Git - python/commitdiff
bpo-31877: Add _Py_LegacyLocaleDetected and _PyCoerceLegacyLocale to pylifecycle...
authorErik Bray <erik.m.bray@gmail.com>
Fri, 27 Oct 2017 09:46:03 +0000 (11:46 +0200)
committerNick Coghlan <ncoghlan@gmail.com>
Fri, 27 Oct 2017 09:46:03 +0000 (19:46 +1000)
Only declaring these as interns inside the CLI's main C module
caused build problems on some platforms (notably Cygwin), so
this switches them to a regular underscore prefixed "private" C
API declaration.

Include/pylifecycle.h
Programs/python.c

index e1737b5972b39a4654ac4c2ceac1eac50de2cdf4..8bbce7fd61dc7c4fe48c4cb4a22264c1d3d862f5 100644 (file)
@@ -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
index 03f8295045cfc65609ea742d5f8dcc3cefa1e44c..4f6b9198c8504efdc0c854376eda5cb5907773e8 100644 (file)
@@ -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();
     }