mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
Guido has Spoken. Restore strop.replace()'s treatment of a 0 count as
meaning infinity -- but at least warn about it in the code! I pissed away a couple hours on this today, and don't wish the same on the next in line. Bugfix candidate.
This commit is contained in:
parent
da45d55a6e
commit
1ee77d9b71
2 changed files with 9 additions and 1 deletions
|
|
@ -1132,6 +1132,12 @@ strop_replace(PyObject *self, PyObject *args)
|
|||
PyErr_SetString(PyExc_ValueError, "empty pattern string");
|
||||
return NULL;
|
||||
}
|
||||
/* CAUTION: strop treats a replace count of 0 as infinity, unlke
|
||||
* current (2.1) string.py and string methods. Preserve this for
|
||||
* ... well, hard to say for what <wink>.
|
||||
*/
|
||||
if (count == 0)
|
||||
count = -1;
|
||||
new_s = mymemreplace(str,len,pat,pat_len,sub,sub_len,count,&out_len);
|
||||
if (new_s == NULL) {
|
||||
PyErr_NoMemory();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue