mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
replace() uses unicode_fromascii() if the input and replace string is ASCII
This commit is contained in:
parent
0617b6e18b
commit
f48323e3b3
1 changed files with 4 additions and 1 deletions
|
@ -9708,6 +9708,9 @@ replace(PyObject *self, PyObject *str1,
|
|||
sbuf + PyUnicode_KIND_SIZE(rkind, i),
|
||||
PyUnicode_KIND_SIZE(rkind, slen-i));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue