diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-05 09:33:00 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-05 09:33:00 (GMT) |
commit | dbb7b9da61450142e034c4da2eb9ca0f0bc13eb0 (patch) | |
tree | 0b30d2c9ced4f7fcb221555bff4c145efdd340ec /Modules | |
parent | 50ab942741a94cc31c6a5036e6b230dc9e1d5689 (diff) | |
download | cpython-dbb7b9da61450142e034c4da2eb9ca0f0bc13eb0.zip cpython-dbb7b9da61450142e034c4da2eb9ca0f0bc13eb0.tar.gz cpython-dbb7b9da61450142e034c4da2eb9ca0f0bc13eb0.tar.bz2 |
Fixed problem with missing PyInt_CheckExact() macro in _ctypes.c
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 00643ac..54e7963 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -954,8 +954,8 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) StgDictObject *itemdict; PyObject *proto; PyObject *typedict; - int length; - + long length; + int overflow; Py_ssize_t itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); @@ -963,13 +963,18 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; proto = PyDict_GetItemString(typedict, "_length_"); /* Borrowed ref */ - if (!proto || !PyInt_CheckExact(proto)) { + if (!proto || !PyLong_Check(proto)) { PyErr_SetString(PyExc_AttributeError, "class must define a '_length_' attribute, " "which must be a positive integer"); return NULL; } - length = PyLong_AS_LONG(proto); + length = PyLong_AsLongAndOverflow(proto, &overflow); + if (overflow) { + PyErr_SetString(PyExc_OverflowError, + "The '_length_' attribute is too large"); + return NULL; + } proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */ if (!proto) { |