Skip to content

Commit

Permalink
fix spacing, add empty string tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sweeneyde committed Jul 13, 2023
1 parent 233ac47 commit 819f8c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ test_bytes_find(PyObject *self, PyObject *Py_UNUSED(args))
} \
} while (0)

CHECK("", "", 0, 0);
CHECK("Python", "", 0, 0);
CHECK("Python", "", 3, 3);
CHECK("Python", "yth", 0, 1);
CHECK("ython", "yth", 1, 1);
CHECK("thon", "yth", 2, -1);
Expand Down
4 changes: 2 additions & 2 deletions Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,8 @@ _PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
return -1;
}
assert(len_haystack >= 1);
Py_ssize_t res = stringlib_find(haystack, len_haystack - 1,
needle, len_needle, offset);
Py_ssize_t res = stringlib_find(haystack, len_haystack - 1,
needle, len_needle, offset);
if (res == -1) {
Py_ssize_t last_align = len_haystack - len_needle;
if (memcmp(haystack + last_align, needle, len_needle) == 0) {
Expand Down

0 comments on commit 819f8c2

Please sign in to comment.