diff -r eee959fee5f5 Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py Sat May 07 21:13:50 2016 +0300 +++ b/Lib/test/test_cmd_line.py Fri May 13 10:36:37 2016 +0200 @@ -8,6 +8,7 @@ import sys import subprocess import tempfile +import platform from test.support import script_helper from test.support.script_helper import (spawn_python, kill_python, assert_python_ok, assert_python_failure) @@ -178,8 +179,9 @@ if not stdout.startswith(pattern): raise AssertionError("%a doesn't start with %a" % (stdout, pattern)) - @unittest.skipUnless(sys.platform == 'darwin', 'test specific to Mac OS X') - def test_osx_utf8(self): + @unittest.skipUnless((sys.platform == 'darwin' or + platform.android_ver()[0]), 'test specific to Mac OS X and Android') + def test_osx_android_utf8(self): def check_output(text): decoded = text.decode('utf-8', 'surrogateescape') expected = ascii(decoded).encode('ascii') + b'\n' diff -r eee959fee5f5 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sat May 07 21:13:50 2016 +0300 +++ b/Objects/unicodeobject.c Fri May 13 10:42:24 2016 +0200 @@ -4982,10 +4982,10 @@ return NULL; } -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) /* Simplified UTF-8 decoder using surrogateescape error handler, - used to decode the command line arguments on Mac OS X. + used to decode the command line arguments on Mac OS X and Android. Return a pointer to a newly allocated wide character string (use PyMem_RawFree() to free the memory), or NULL on memory allocation error. */ @@ -5036,7 +5036,7 @@ return unicode; } -#endif /* __APPLE__ */ +#endif /* __APPLE__ or __ANDROID__ */ /* Primary internal function which creates utf8 encoded bytes objects. diff -r eee959fee5f5 Python/fileutils.c --- a/Python/fileutils.c Sat May 07 21:13:50 2016 +0300 +++ b/Python/fileutils.c Fri May 13 10:43:11 2016 +0200 @@ -20,7 +20,7 @@ #include #endif /* HAVE_FCNTL_H */ -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); #endif @@ -272,7 +272,7 @@ wchar_t* Py_DecodeLocale(const char* arg, size_t *size) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) wchar_t *wstr; wstr = _Py_DecodeUTF8_surrogateescape(arg, strlen(arg)); if (size != NULL) { @@ -405,7 +405,7 @@ if (size != NULL) *size = (size_t)-1; return NULL; -#endif /* __APPLE__ */ +#endif /* __APPLE__ or __ANDROID__ */ } /* Encode a wide character string to the locale encoding with the @@ -423,7 +423,7 @@ char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) Py_ssize_t len; PyObject *unicode, *bytes = NULL; char *cpath; @@ -521,7 +521,7 @@ bytes = result; } return result; -#endif /* __APPLE__ */ +#endif /* __APPLE__ or __ANDROID__ */ }