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

WildCard65 webhook-mailer at python.org
Tue Jun 23 09:21:21 EDT 2020


https://github.com/python/cpython/commit/1d3dad5f96ed445b958ec53dfa0d46812f2162d9
commit: 1d3dad5f96ed445b958ec53dfa0d46812f2162d9
branch: master
author: WildCard65 <WildCard65 at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-06-23T15:21:16+02:00
summary:

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``.

files:
A Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst
M Modules/arraymodule.c

diff --git a/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst b/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst
new file mode 100644
index 0000000000000..463dffdd653ee
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-06-23-12-02-45.bpo-41085.JZKsyz.rst
@@ -0,0 +1,2 @@
+Fix integer overflow in the :meth:`array.array.index` method on 64-bit Windows
+for index larger than ``2**31``.
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 8f12c61646335..2d498c7e82941 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1130,7 +1130,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;



More information about the Python-checkins mailing list