]> granicus.if.org Git - python/commitdiff
PySequence_Index(): set exception when object is not found in
authorBarry Warsaw <barry@python.org>
Wed, 18 Dec 1996 19:32:18 +0000 (19:32 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 18 Dec 1996 19:32:18 +0000 (19:32 +0000)
sequence, otherwise

operator.indexOf([4, 3, 2, 1], 9) would raise a SystemError!

Note: it might be wise to double check all these functions.  I haven't
done that yet.

Objects/abstract.c

index a8823eb5a2308c7439c75770e6381507baffde1b..cac767fbfee6a201e1b4a6f0675744c1ff749cfe 100644 (file)
@@ -912,6 +912,7 @@ PySequence_Index(s, o)
       if(err) return -1;
       if(! not_equal) return i;
     }
+  PyErr_SetString(PyExc_ValueError, "list.index(x): x not in list");
   return -1;
 }