fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on

the current behaviour ;-)
This commit is contained in:
Fredrik Lundh 2006-05-29 22:42:07 +00:00
parent a355c14fa1
commit b51b470eb8
2 changed files with 12 additions and 1 deletions

View file

@ -13,8 +13,11 @@ stringlib_count(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
{
Py_ssize_t count;
if (sub_len == 0)
if (sub_len == 0) {
if (str_len < 0)
return 1; /* start >= len(str) */
return str_len + 1;
}
count = fastsearch(str, str_len, sub, sub_len, FAST_COUNT);