summaryrefslogtreecommitdiffstats
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-05-10 01:23:39 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-05-10 01:23:39 (GMT)
commit1ee77d9b71dab3b42b3c00760216cc4955a3cfeb (patch)
tree835e226526d2abef1f1eeef68e4fe758fbc40a40 /Modules/stropmodule.c
parentda45d55a6ecff00ca714cbcf66fb2133621ca836 (diff)
downloadcpython-1ee77d9b71dab3b42b3c00760216cc4955a3cfeb.zip
cpython-1ee77d9b71dab3b42b3c00760216cc4955a3cfeb.tar.gz
cpython-1ee77d9b71dab3b42b3c00760216cc4955a3cfeb.tar.bz2
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.
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index aa9cdc7..312e0dc 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -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();