Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
sobolevn committed Oct 8, 2022
commit 35ecc77deb4c38f082842ff777f1af67730236a7

This file was deleted.

20 changes: 9 additions & 11 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8965,10 +8965,10 @@ _PyUnicode_InsertThousandsGrouping(
}

static Py_ssize_t
any_unicode_count(PyObject *str,
PyObject *substr,
Py_ssize_t start,
Py_ssize_t end)
unicode_count_impl(PyObject *str,
Comment thread
vstinner marked this conversation as resolved.
PyObject *substr,
Py_ssize_t start,
Py_ssize_t end)
{
assert(PyUnicode_Check(str));
assert(PyUnicode_Check(substr));
Expand Down Expand Up @@ -9047,7 +9047,7 @@ PyUnicode_Count(PyObject *str,
if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
return -1;

return any_unicode_count(str, substr, start, end);
return unicode_count_impl(str, substr, start, end);
}

Py_ssize_t
Expand Down Expand Up @@ -10868,18 +10868,16 @@ unicode_count(PyObject *self, PyObject *args)
PyObject *substring = NULL; /* initialize to fix a compiler warning */
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
PyObject *result;
Py_ssize_t iresult;
Py_ssize_t result;

if (!parse_args_finds_unicode("count", args, &substring, &start, &end))
return NULL;

iresult = any_unicode_count(self, substring, start, end);
if (iresult == -1)
result = unicode_count_impl(self, substring, start, end);
if (result == -1)
return NULL;

result = PyLong_FromSsize_t(iresult);
return result;
return PyLong_FromSsize_t(result);
}

/*[clinic input]
Expand Down