Issue #24284: The startswith and endswith methods of the str class no longer
return True when finding the empty string and the indexes are completely out
of range.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 84e67e6..1eaf2e9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9280,14 +9280,14 @@
PyUnicode_READY(substring) == -1)
return -1;
- if (PyUnicode_GET_LENGTH(substring) == 0)
- return 1;
-
ADJUST_INDICES(start, end, PyUnicode_GET_LENGTH(self));
end -= PyUnicode_GET_LENGTH(substring);
if (end < start)
return 0;
+ if (PyUnicode_GET_LENGTH(substring) == 0)
+ return 1;
+
kind_self = PyUnicode_KIND(self);
data_self = PyUnicode_DATA(self);
kind_sub = PyUnicode_KIND(substring);