diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-10-30 10:03:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-30 10:03:53 (GMT) |
commit | 865c3b257fe38154a4320c7ee6afb416f665b9c2 (patch) | |
tree | ab97967500a250cac15ac0d69aeb2c061bf313ba /Objects/unicodeobject.c | |
parent | 25fc088607c855060ed142296dc1bd0125fad1af (diff) | |
download | cpython-865c3b257fe38154a4320c7ee6afb416f665b9c2.zip cpython-865c3b257fe38154a4320c7ee6afb416f665b9c2.tar.gz cpython-865c3b257fe38154a4320c7ee6afb416f665b9c2.tar.bz2 |
bpo-28029: Make "".replace("", s, n) returning s for any n != 0. (GH-16981)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2d60627..5ae0af8 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -10572,9 +10572,12 @@ replace(PyObject *self, PyObject *str1, int mayshrink; Py_UCS4 maxchar, maxchar_str1, maxchar_str2; + if (slen < len1) + goto nothing; + if (maxcount < 0) maxcount = PY_SSIZE_T_MAX; - else if (maxcount == 0 || slen == 0) + else if (maxcount == 0) goto nothing; if (str1 == str2) |