summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-09 15:36:48 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-09 15:36:48 (GMT)
commitf36921c4b0ca499134b44ff3594c6c43768799c2 (patch)
tree18a7adf8b50de381b1d498382ea3163068845eb6 /Objects
parent3bc3f28dbec7ec3f221d9293e05e0cf1ba5f20aa (diff)
downloadcpython-f36921c4b0ca499134b44ff3594c6c43768799c2.zip
cpython-f36921c4b0ca499134b44ff3594c6c43768799c2.tar.gz
cpython-f36921c4b0ca499134b44ff3594c6c43768799c2.tar.bz2
Unicode replace() method with empty pattern argument should fail, like
it does for 8-bit strings.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 03b5dbd..d6fd62a 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3455,6 +3455,11 @@ PyObject *replace(PyUnicodeObject *self,
{
PyUnicodeObject *u;
+ if (str1->length == 0) {
+ PyErr_SetString(PyExc_ValueError, "empty pattern string");
+ return NULL;
+ }
+
if (maxcount < 0)
maxcount = INT_MAX;