diff options
author | doko <doko@ubuntu.com> | 2017-01-31 13:35:56 +0100 |
---|---|---|
committer | doko <doko@ubuntu.com> | 2017-01-31 13:35:56 +0100 |
commit | b23072b8814146d3a76eb752fd7526eb1575e7cc (patch) | |
tree | cf13a75e5570561a10bf68c2c451e9271229a3be /Lib/_bootlocale.py | |
parent | e0cb38ac4330d5e09b5e21c74c5d5e453af99a4f (diff) | |
parent | ccd19e48ec9d557231bf923c338be0e7509a51d3 (diff) | |
download | cpython-b23072b8814146d3a76eb752fd7526eb1575e7cc.tar.gz |
merge 3.6
Diffstat (limited to 'Lib/_bootlocale.py')
-rw-r--r-- | Lib/_bootlocale.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/_bootlocale.py b/Lib/_bootlocale.py index 4bccac1139..0c61b0d3a0 100644 --- a/Lib/_bootlocale.py +++ b/Lib/_bootlocale.py @@ -14,11 +14,17 @@ else: try: _locale.CODESET except AttributeError: - def getpreferredencoding(do_setlocale=True): - # This path for legacy systems needs the more complex - # getdefaultlocale() function, import the full locale module. - import locale - return locale.getpreferredencoding(do_setlocale) + if hasattr(sys, 'getandroidapilevel'): + # On Android langinfo.h and CODESET are missing, and UTF-8 is + # always used in mbstowcs() and wcstombs(). + def getpreferredencoding(do_setlocale=True): + return 'UTF-8' + else: + def getpreferredencoding(do_setlocale=True): + # This path for legacy systems needs the more complex + # getdefaultlocale() function, import the full locale module. + import locale + return locale.getpreferredencoding(do_setlocale) else: def getpreferredencoding(do_setlocale=True): assert not do_setlocale |