[Python-checkins] cpython: replace() uses unicode_fromascii() if the input and replace string is ASCII
victor.stinner
python-checkins at python.org
Thu Oct 6 01:51:00 CEST 2011
http://hg.python.org/cpython/rev/b2330e70b41e
changeset: 72712:b2330e70b41e
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed Oct 05 23:27:08 2011 +0200
summary:
replace() uses unicode_fromascii() if the input and replace string is ASCII
files:
Objects/unicodeobject.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9708,7 +9708,10 @@
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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list