diff -ru Python-3.3.5/Modules/Setup.dist Python-3.3.5-android/Modules/Setup.dist --- Python-3.3.5/Modules/Setup.dist 2014-03-09 09:40:23.000000000 +0100 +++ Python-3.3.5-android/Modules/Setup.dist 2014-08-04 22:16:29.000000000 +0200 @@ -118,7 +118,7 @@ itertools itertoolsmodule.c # Functions creating iterators for efficient looping # access to ISO C locale support -_locale _localemodule.c # -lintl +#_locale _localemodule.c # -lintl # Standard I/O baseline _io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c diff -ru Python-3.3.5/Modules/_decimal/libmpdec/io.c Python-3.3.5-android/Modules/_decimal/libmpdec/io.c --- Python-3.3.5/Modules/_decimal/libmpdec/io.c 2014-03-09 09:40:25.000000000 +0100 +++ Python-3.3.5-android/Modules/_decimal/libmpdec/io.c 2014-08-04 22:16:29.000000000 +0200 @@ -868,10 +868,17 @@ } spec->type = *cp++; spec->type = (spec->type == 'N') ? 'G' : 'g'; +#ifdef __ANDROID__ + spec->dot = "."; + spec->sep = ","; + spec->grouping = "\3"; +#else lc = localeconv(); spec->dot = lc->decimal_point; spec->sep = lc->thousands_sep; spec->grouping = lc->grouping; +#endif + if (mpd_validate_lconv(spec) < 0) { return 0; /* GCOV_NOT_REACHED */ } diff -ru Python-3.3.5/Modules/_localemodule.c Python-3.3.5-android/Modules/_localemodule.c --- Python-3.3.5/Modules/_localemodule.c 2014-03-09 09:40:26.000000000 +0100 +++ Python-3.3.5-android/Modules/_localemodule.c 2014-08-04 22:16:29.000000000 +0200 @@ -38,6 +38,13 @@ #include #endif +#if __ANDROID__ +/* Android's locale support is pretty much unusable, it's better to have the + higher-level module fall back to C locale emulation. */ +#error "Android's locale support is too incomplete to create a usable module." +#endif + + PyDoc_STRVAR(locale__doc__, "Support for POSIX locales."); static PyObject *Error; @@ -141,6 +148,11 @@ if (!result) return NULL; +#ifdef __ANDROID__ + /* Don't even try on Android's broken locale.h. */ + goto failed; +#else + /* if LC_NUMERIC is different in the C library, use saved value */ l = localeconv(); @@ -189,6 +201,7 @@ RESULT_INT(p_sign_posn); RESULT_INT(n_sign_posn); return result; +#endif // __ANDROID__ failed: Py_XDECREF(result); diff -ru Python-3.3.5/Modules/main.c Python-3.3.5-android/Modules/main.c --- Python-3.3.5/Modules/main.c 2014-03-09 09:40:27.000000000 +0100 +++ Python-3.3.5-android/Modules/main.c 2014-08-04 22:16:29.000000000 +0200 @@ -522,7 +522,7 @@ oldloc = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, ""); for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) /* Use utf-8 on Mac OS X */ unicode = PyUnicode_FromString(p); #else diff -ru Python-3.3.5/Objects/unicodeobject.c Python-3.3.5-android/Objects/unicodeobject.c --- Python-3.3.5/Objects/unicodeobject.c 2014-03-09 09:40:30.000000000 +0100 +++ Python-3.3.5-android/Objects/unicodeobject.c 2014-08-04 22:16:29.000000000 +0200 @@ -3295,13 +3295,22 @@ static int locale_error_handler(const char *errors, int *surrogateescape) { + if (errors == NULL) { +#ifdef __ANDROID__ + *surrogateescape = 1; +#else *surrogateescape = 0; +#endif return 0; } if (strcmp(errors, "strict") == 0) { +#ifdef __ANDROID__ + *surrogateescape = 1; +#else *surrogateescape = 0; +#endif return 0; } if (strcmp(errors, "surrogateescape") == 0) { @@ -3429,7 +3438,7 @@ { #ifdef HAVE_MBCS return PyUnicode_EncodeCodePage(CP_ACP, unicode, NULL); -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__ANDROID__) return _PyUnicode_AsUTF8String(unicode, "surrogateescape"); #else PyInterpreterState *interp = PyThreadState_GET()->interp; @@ -3709,7 +3718,7 @@ { #ifdef HAVE_MBCS return PyUnicode_DecodeMBCS(s, size, NULL); -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__ANDROID__) return PyUnicode_DecodeUTF8Stateful(s, size, "surrogateescape", NULL); #else PyInterpreterState *interp = PyThreadState_GET()->interp; @@ -4835,7 +4844,7 @@ 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. diff -ru Python-3.3.5/Python/bltinmodule.c Python-3.3.5-android/Python/bltinmodule.c --- Python-3.3.5/Python/bltinmodule.c 2014-03-09 09:40:32.000000000 +0100 +++ Python-3.3.5-android/Python/bltinmodule.c 2014-08-04 22:16:29.000000000 +0200 @@ -24,7 +24,7 @@ #ifdef HAVE_MBCS const char *Py_FileSystemDefaultEncoding = "mbcs"; int Py_HasFileSystemDefaultEncoding = 1; -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__ANDROID__) const char *Py_FileSystemDefaultEncoding = "utf-8"; int Py_HasFileSystemDefaultEncoding = 1; #else diff -ru Python-3.3.5/Python/fileutils.c Python-3.3.5-android/Python/fileutils.c --- Python-3.3.5/Python/fileutils.c 2014-03-09 09:40:32.000000000 +0100 +++ Python-3.3.5-android/Python/fileutils.c 2014-08-04 22:16:29.000000000 +0200 @@ -10,7 +10,7 @@ #include #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__ANDROID__) extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); #endif @@ -44,7 +44,7 @@ Py_RETURN_NONE; } -#if !defined(__APPLE__) && !defined(MS_WINDOWS) +#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(MS_WINDOWS) extern int _Py_normalize_encoding(const char *, char *, size_t); /* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. @@ -194,7 +194,7 @@ } #endif /* !defined(__APPLE__) && !defined(MS_WINDOWS) */ -#if !defined(__APPLE__) && (!defined(MS_WINDOWS) || !defined(HAVE_MBRTOWC)) +#if !defined(__APPLE__) && !defined(__ANDROID__) && (!defined(MS_WINDOWS) || !defined(HAVE_MBRTOWC)) static wchar_t* decode_ascii_surrogateescape(const char *arg, size_t *size) { @@ -241,7 +241,7 @@ wchar_t* _Py_char2wchar(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) { @@ -384,7 +384,7 @@ char* _Py_wchar2char(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; diff -ru Python-3.3.5/Python/formatter_unicode.c Python-3.3.5-android/Python/formatter_unicode.c --- Python-3.3.5/Python/formatter_unicode.c 2014-03-09 09:40:32.000000000 +0100 +++ Python-3.3.5-android/Python/formatter_unicode.c 2014-08-04 22:16:29.000000000 +0200 @@ -665,6 +665,7 @@ { switch (type) { case LT_CURRENT_LOCALE: { +#ifndef __ANDROID__ struct lconv *locale_data = localeconv(); locale_info->decimal_point = PyUnicode_DecodeLocale( locale_data->decimal_point, @@ -680,6 +681,7 @@ } locale_info->grouping = locale_data->grouping; break; +#endif // __ANDROID__ } case LT_DEFAULT_LOCALE: locale_info->decimal_point = PyUnicode_FromOrdinal('.'); diff -ru Python-3.3.5/Python/pystrtod.c Python-3.3.5-android/Python/pystrtod.c --- Python-3.3.5/Python/pystrtod.c 2014-03-09 09:40:33.000000000 +0100 +++ Python-3.3.5-android/Python/pystrtod.c 2014-08-04 22:16:29.000000000 +0200 @@ -177,8 +177,12 @@ fail_pos = NULL; +#ifdef __ANDROID__ + decimal_point = "."; +#else locale_data = localeconv(); decimal_point = locale_data->decimal_point; +#endif decimal_point_len = strlen(decimal_point); assert(decimal_point_len != 0); @@ -378,8 +382,12 @@ Py_LOCAL_INLINE(void) change_decimal_from_locale_to_dot(char* buffer) { +#ifdef __ANDROID__ + const char *decimal_point = "."; +#else struct lconv *locale_data = localeconv(); const char *decimal_point = locale_data->decimal_point; +#endif if (decimal_point[0] != '.' || decimal_point[1] != 0) { size_t decimal_point_len = strlen(decimal_point); diff -ru Python-3.3.5/Python/pythonrun.c Python-3.3.5-android/Python/pythonrun.c --- Python-3.3.5/Python/pythonrun.c 2014-03-09 09:40:33.000000000 +0100 +++ Python-3.3.5-android/Python/pythonrun.c 2014-08-04 22:16:29.000000000 +0200 @@ -188,6 +188,8 @@ return NULL; } return get_codec_name(codeset); +#elif __ANDROID__ + return get_codec_name("UTF-8"); #else PyErr_SetNone(PyExc_NotImplementedError); return NULL;