This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients SilentGhost, WildCard65, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2020-06-23.10:47:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592909257.55.0.857956504773.issue41085@roundup.psfhosted.org>
In-reply-to
Content
That's a bug in array_array_index() which downcasts "Py_ssize_t i" to long:

static PyObject *
array_array_index(arrayobject *self, PyObject *v)
/*[clinic end generated code: output=d48498d325602167 input=cf619898c6649d08]*/
{
    Py_ssize_t i;

    for (i = 0; i < Py_SIZE(self); i++) {
        PyObject *selfi;
        int cmp;

        selfi = getarrayitem((PyObject *)self, i);
        if (selfi == NULL)
            return NULL;
        cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
        Py_DECREF(selfi);
        if (cmp > 0) {
            return PyLong_FromLong((long)i); // <===== HERE ===
        }
        else if (cmp < 0)
            return NULL;
    }
    PyErr_SetString(PyExc_ValueError, "array.index(x): x not in array");
    return NULL;
}
History
Date User Action Args
2020-06-23 10:47:37vstinnersetrecipients: + vstinner, paul.moore, tim.golden, SilentGhost, zach.ware, steve.dower, WildCard65
2020-06-23 10:47:37vstinnersetmessageid: <1592909257.55.0.857956504773.issue41085@roundup.psfhosted.org>
2020-06-23 10:47:37vstinnerlinkissue41085 messages
2020-06-23 10:47:37vstinnercreate