Issue #13706: Fix format(float, "n") for locale with non-ASCII decimal point (e.g. ps_aF)

This commit is contained in:
Victor Stinner 2012-02-24 01:44:47 +01:00
parent 6858cabb26
commit 90f50d4df9
3 changed files with 31 additions and 15 deletions

View file

@ -9176,9 +9176,16 @@ _PyUnicode_InsertThousandsGrouping(
thousands_sep_data = PyUnicode_DATA(thousands_sep);
thousands_sep_len = PyUnicode_GET_LENGTH(thousands_sep);
if (unicode != NULL && thousands_sep_kind != kind) {
thousands_sep_data = _PyUnicode_AsKind(thousands_sep, kind);
if (!thousands_sep_data)
return -1;
if (thousands_sep_kind < kind) {
thousands_sep_data = _PyUnicode_AsKind(thousands_sep, kind);
if (!thousands_sep_data)
return -1;
}
else {
data = _PyUnicode_AsKind(unicode, thousands_sep_kind);
if (!data)
return -1;
}
}
switch (kind) {
@ -9210,8 +9217,12 @@ _PyUnicode_InsertThousandsGrouping(
assert(0);
return -1;
}
if (unicode != NULL && thousands_sep_kind != kind)
PyMem_Free(thousands_sep_data);
if (unicode != NULL && thousands_sep_kind != kind) {
if (thousands_sep_kind < kind)
PyMem_Free(thousands_sep_data);
else
PyMem_Free(data);
}
if (unicode == NULL) {
*maxchar = 127;
if (len != n_digits) {