Author: christian.heimes
Date: Wed Dec  5 10:33:00 2007
New Revision: 59344

Modified:
   python/branches/py3k/Modules/_ctypes/_ctypes.c
Log:
Fixed problem with missing PyInt_CheckExact() macro in _ctypes.c

Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/_ctypes.c      (original)
+++ python/branches/py3k/Modules/_ctypes/_ctypes.c      Wed Dec  5 10:33:00 2007
@@ -954,8 +954,8 @@
        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 @@
                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) {
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to