Xavier de Gaye added the comment:
pep538_coerce_legacy_c_locale_v3.diff fixes issue 28997 on Android (api 21 and
24). This issue is raised because there is an inconsistency between Python on
Android that considers the locale encoding to be always UTF-8 and GNU Readline
that does not accept eight-bit characters when LANG is not set (on Android).
On Android, setlocale(CATEGORY, "") does not look for the locale environment
variables (LANG, ...) but sets the 'C' locale instead, so the patch does not
fully behave as expected and the 'Py_Initialize detected' warning is emitted.
Here is the output of an interactive session on Android:
root@generic_x86:/data/data/org.bitbucket.pyona # python
Python detected LC_CTYPE=C, forcing LC_ALL & LANG to C.UTF-8 (set
PYTHONALLOWCLOCALE to disable this locale coercion behaviour).
Py_Initialize detected LC_CTYPE=C, which limits Unicode compatibility. Some
libraries and operating system interfaces may not work correctly. Set
`PYTHONALLOWCLOCALE=1 LC_CTYPE=C` to configure a similar environment when
running Python directly.
Python 3.7.0a0 (default:0503024831ad+, Jan 18 2017, 11:34:53)
[GCC 4.2.1 Compatible Android Clang 3.8.256229 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale, os
>>> os.environ['LANG']
'C.UTF-8'
>>> locale.getdefaultlocale()
('en_US', 'UTF-8')
>>> locale.setlocale(locale.LC_CTYPE)
'C'
>>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
'C.UTF-8'
>>> locale.setlocale(locale.LC_CTYPE)
'C.UTF-8'
The attached android_setlocale.patch fixes the following problems when applied
after pep538_coerce_legacy_c_locale_v3.diff:
* No 'Py_Initialize detected' warning is emitted.
* locale.setlocale(locale.LC_CTYPE) returns now 'C.UTF-8'.
----------
nosy: +xdegaye
Added file: http://bugs.python.org/file46329/android_setlocale.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28180>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com