diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c --- a/Modules/_decimal/libmpdec/io.c +++ b/Modules/_decimal/libmpdec/io.c @@ -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 --git a/Modules/_localemodule.c b/Modules/_localemodule.c --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -141,6 +141,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(); @@ -195,6 +200,7 @@ RESULT_INT(p_sign_posn); RESULT_INT(n_sign_posn); return result; +#endif // __ANDROID__ failed: Py_XDECREF(result); diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -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 --git a/Python/pystrtod.c b/Python/pystrtod.c --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -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);