[Python-checkins] cpython: make fix_decimal_and_space_to_ascii check if it modifies the string
benjamin.peterson
python-checkins at python.org
Thu Jan 12 21:40:23 CET 2012
http://hg.python.org/cpython/rev/c9ead1b5ca85
changeset: 74351:c9ead1b5ca85
user: Benjamin Peterson <benjamin at python.org>
date: Thu Jan 12 15:40:18 2012 -0500
summary:
make fix_decimal_and_space_to_ascii check if it modifies the string
files:
Objects/unicodeobject.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8845,6 +8845,7 @@
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 @@
fixed = '0' + decimal;
}
if (fixed != 0) {
+ modified = 1;
if (fixed > maxchar)
maxchar = fixed;
PyUnicode_WRITE(kind, data, i, fixed);
@@ -8870,7 +8872,7 @@
maxchar = ch;
}
- return maxchar;
+ return (modified) ? maxchar : 0;
}
PyObject *
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list