]> granicus.if.org Git - python/commitdiff
Correct an accidentally removed previous patch.
authorMarc-André Lemburg <mal@egenix.com>
Mon, 14 Aug 2006 12:57:27 +0000 (12:57 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Mon, 14 Aug 2006 12:57:27 +0000 (12:57 +0000)
Objects/unicodeobject.c

index f4e37556e567a7fd785b9e2dc0042b904242506c..d93f780ded10075ef5156de3e883ecc67b5da6a3 100644 (file)
@@ -7061,14 +7061,11 @@ static PySequenceMethods unicode_as_sequence = {
     PyUnicode_Contains,                /* sq_contains */
 };
 
-#define HASINDEX(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_HAVE_INDEX)
-
 static PyObject*
 unicode_subscript(PyUnicodeObject* self, PyObject* item)
 {
-    PyNumberMethods *nb = item->ob_type->tp_as_number;
-    if (nb != NULL && HASINDEX(item) && nb->nb_index != NULL) {
-        Py_ssize_t i = nb->nb_index(item);
+    if (PyIndex_Check(item)) {
+        Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
         if (i == -1 && PyErr_Occurred())
             return NULL;
         if (i < 0)