mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
This commit is contained in:
parent
a355c14fa1
commit
b51b470eb8
2 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue