Commit 821e4cfd authored by Benjamin Peterson's avatar Benjamin Peterson

make fix_decimal_and_space_to_ascii check if it modifies the string

parent 1adbc6f5
...@@ -8845,6 +8845,7 @@ fix_decimal_and_space_to_ascii(PyObject *self) ...@@ -8845,6 +8845,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
const int kind = PyUnicode_KIND(self); const int kind = PyUnicode_KIND(self);
void *data = PyUnicode_DATA(self); void *data = PyUnicode_DATA(self);
Py_UCS4 maxchar = 0, ch, fixed; Py_UCS4 maxchar = 0, ch, fixed;
int modified = 0;
Py_ssize_t i; Py_ssize_t i;
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
...@@ -8859,6 +8860,7 @@ fix_decimal_and_space_to_ascii(PyObject *self) ...@@ -8859,6 +8860,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
fixed = '0' + decimal; fixed = '0' + decimal;
} }
if (fixed != 0) { if (fixed != 0) {
modified = 1;
if (fixed > maxchar) if (fixed > maxchar)
maxchar = fixed; maxchar = fixed;
PyUnicode_WRITE(kind, data, i, fixed); PyUnicode_WRITE(kind, data, i, fixed);
...@@ -8870,7 +8872,7 @@ fix_decimal_and_space_to_ascii(PyObject *self) ...@@ -8870,7 +8872,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
maxchar = ch; maxchar = ch;
} }
return maxchar; return (modified) ? maxchar : 0;
} }
PyObject * PyObject *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment