Issue 3301: Bisect functions behaved badly when lo was negative.
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
index f8d412a..4870e5d 100644
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -11,6 +11,10 @@
PyObject *litem;
Py_ssize_t mid, res;
+ if (lo < 0) {
+ PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
+ return -1;
+ }
if (hi == -1) {
hi = PySequence_Size(list);
if (hi < 0)
@@ -108,6 +112,10 @@
PyObject *litem;
int mid, res;
+ if (lo < 0) {
+ PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
+ return -1;
+ }
if (hi == -1) {
hi = PySequence_Size(list);
if (hi < 0)