diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-05-15 05:40:27 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-15 05:40:27 (GMT) |
| commit | 2ce72e243fbc0e4f07f1191b20be548bfa5cbe11 (patch) | |
| tree | fd2e49f2ed91f14d89cfb998b23570359c33828e /Modules | |
| parent | cc598ae26447a10d1580d95b8442e8ce3c68baea (diff) | |
| download | cpython-2ce72e243fbc0e4f07f1191b20be548bfa5cbe11.zip cpython-2ce72e243fbc0e4f07f1191b20be548bfa5cbe11.tar.gz cpython-2ce72e243fbc0e4f07f1191b20be548bfa5cbe11.tar.bz2 | |
bpo-16865: Support arrays >=2GB in ctypes. (GH-3006)
(cherry picked from commit 735abadd5bd91db4a9e6f4311969b0afacca0a1a)
Co-authored-by: Segev Finer <segev208@gmail.com>
Diffstat (limited to 'Modules')
| -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 93e8d8d..66bce15 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) { |
