From 96a45adf808ee9798d0c2637aeed2c895fa8e929 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 13 Mar 2000 15:56:08 +0000 Subject: Fix typo in replace() detected by Mark Hammond and fixed by Marc-Andre. --- Objects/stringobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/stringobject.c b/Objects/stringobject.c index c83983f..2d404b9 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -389,7 +389,9 @@ PyObject *a, *el; { register char *s, *end; register char c; - if (!PyString_Check(el) || PyString_Size(el) != 1) { + if (!PyString_Check(el)) + return PyUnicode_Contains(a, el); + if (PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, "string member test needs char left operand"); return -1; @@ -1575,7 +1577,7 @@ string_replace(self, args) else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len)) return NULL; - if (repl_len <= 0) { + if (sub_len <= 0) { PyErr_SetString(PyExc_ValueError, "empty replacement string"); return NULL; } -- cgit v0.12