summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-05 21:27:08 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-05 21:27:08 (GMT)
commitf48323e3b3336eeb787d94718464e527612ed0fb (patch)
tree092907ba247376123eb4ac788f4c41bda3dc715b /Objects
parent0617b6e18b84d854b0648e0893b62a893b7638fd (diff)
downloadcpython-f48323e3b3336eeb787d94718464e527612ed0fb.zip
cpython-f48323e3b3336eeb787d94718464e527612ed0fb.tar.gz
cpython-f48323e3b3336eeb787d94718464e527612ed0fb.tar.bz2
replace() uses unicode_fromascii() if the input and replace string is ASCII
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index bf2b32a..a0d3056 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9708,7 +9708,10 @@ replace(PyObject *self, PyObject *str1,
sbuf + PyUnicode_KIND_SIZE(rkind, i),
PyUnicode_KIND_SIZE(rkind, slen-i));
}
- u = PyUnicode_FromKindAndData(rkind, res, new_size);
+ if (PyUnicode_IS_ASCII(self) && PyUnicode_IS_ASCII(str2))
+ u = unicode_fromascii((unsigned char*)res, new_size);
+ else
+ u = PyUnicode_FromKindAndData(rkind, res, new_size);
PyMem_Free(res);
}
if (srelease)