bpo-41085: Fix array.array.index() on 64-bit Windows (GH-21071)

Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
for index larger than ``2**31``.
(cherry picked from commit 1d3dad5f96)

Co-authored-by: WildCard65 <WildCard65@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2020-06-23 06:40:47 -07:00 committed by GitHub
parent 56d25add07
commit c6e24e7420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
for index larger than ``2**31``.

View File

@ -1136,7 +1136,7 @@ array_array_index(arrayobject *self, PyObject *v)
cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
Py_DECREF(selfi);
if (cmp > 0) {
return PyLong_FromLong((long)i);
return PyLong_FromSsize_t(i);
}
else if (cmp < 0)
return NULL;