]> granicus.if.org Git - python/commitdiff
make fix_decimal_and_space_to_ascii check if it modifies the string
authorBenjamin Peterson <benjamin@python.org>
Thu, 12 Jan 2012 20:40:18 +0000 (15:40 -0500)
committerBenjamin Peterson <benjamin@python.org>
Thu, 12 Jan 2012 20:40:18 +0000 (15:40 -0500)
Objects/unicodeobject.c

index 69790500faeb518ccc0e5603e322f23138fcad7b..034c6916369a2d8833a44b8a6d27b595a622987f 100644 (file)
@@ -8845,6 +8845,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
     const int kind = PyUnicode_KIND(self);
     void *data = PyUnicode_DATA(self);
     Py_UCS4 maxchar = 0, ch, fixed;
+    int modified = 0;
     Py_ssize_t i;
 
     for (i = 0; i < len; ++i) {
@@ -8859,6 +8860,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
                     fixed = '0' + decimal;
             }
             if (fixed != 0) {
+                modified = 1;
                 if (fixed > maxchar)
                     maxchar = fixed;
                 PyUnicode_WRITE(kind, data, i, fixed);
@@ -8870,7 +8872,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
             maxchar = ch;
     }
 
-    return maxchar;
+    return (modified) ? maxchar : 0;
 }
 
 PyObject *