summaryrefslogtreecommitdiff
path: root/Lib/_bootlocale.py
diff options
context:
space:
mode:
authorMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:18:39 -0800
committerMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:18:39 -0800
commit731cca110f376cdbaffb536e42d6c9d6da574fa8 (patch)
tree9cb95caf6f8b933115820bf699725d9cd600d2df /Lib/_bootlocale.py
parentda79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (diff)
parentc8102f4d974669f4c5e4ca7bcd73292a1ac5bcbf (diff)
downloadcpython-731cca110f376cdbaffb536e42d6c9d6da574fa8.tar.gz
Issue #29371: merge with 3.6
Diffstat (limited to 'Lib/_bootlocale.py')
-rw-r--r--Lib/_bootlocale.py16
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