diff options
author | Segev Finer <segev208@gmail.com> | 2018-05-14 23:54:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-05-14 23:54:29 (GMT) |
commit | 735abadd5bd91db4a9e6f4311969b0afacca0a1a (patch) | |
tree | fb0c6d325e164adf3d52ac63905552d838fd6e24 /Modules/_ctypes | |
parent | d063b84d9ee435e9ae981c18faccaff5562792c3 (diff) | |
download | cpython-735abadd5bd91db4a9e6f4311969b0afacca0a1a.zip cpython-735abadd5bd91db4a9e6f4311969b0afacca0a1a.tar.gz cpython-735abadd5bd91db4a9e6f4311969b0afacca0a1a.tar.bz2 |
bpo-16865: Support arrays >=2GB in ctypes. (GH-3006)
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 5bf49ac..3ae6348 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1390,8 +1390,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) StgDictObject *stgdict; StgDictObject *itemdict; PyObject *length_attr, *type_attr; - long length; - int overflow; + Py_ssize_t length; Py_ssize_t itemsize, itemalign; /* create the new instance (which is a class, @@ -1413,14 +1412,15 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_XDECREF(length_attr); goto error; } - length = PyLong_AsLongAndOverflow(length_attr, &overflow); - if (overflow) { - PyErr_SetString(PyExc_OverflowError, - "The '_length_' attribute is too large"); - Py_DECREF(length_attr); + length = PyLong_AsSsize_t(length_attr); + Py_DECREF(length_attr); + if (length == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) { + PyErr_SetString(PyExc_OverflowError, + "The '_length_' attribute is too large"); + } goto error; } - Py_DECREF(length_attr); type_attr = PyObject_GetAttrString((PyObject *)result, "_type_"); if (!type_attr) { |