Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 821e4cf

Browse files
committed
make fix_decimal_and_space_to_ascii check if it modifies the string
1 parent 1adbc6f commit 821e4cf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Objects/unicodeobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8845,6 +8845,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
88458845
const int kind = PyUnicode_KIND(self);
88468846
void *data = PyUnicode_DATA(self);
88478847
Py_UCS4 maxchar = 0, ch, fixed;
8848+
int modified = 0;
88488849
Py_ssize_t i;
88498850

88508851
for (i = 0; i < len; ++i) {
@@ -8859,6 +8860,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
88598860
fixed = '0' + decimal;
88608861
}
88618862
if (fixed != 0) {
8863+
modified = 1;
88628864
if (fixed > maxchar)
88638865
maxchar = fixed;
88648866
PyUnicode_WRITE(kind, data, i, fixed);
@@ -8870,7 +8872,7 @@ fix_decimal_and_space_to_ascii(PyObject *self)
88708872
maxchar = ch;
88718873
}
88728874

8873-
return maxchar;
8875+
return (modified) ? maxchar : 0;
88748876
}
88758877

88768878
PyObject *

0 commit comments

Comments
 (0)