Index: Lib/ctypes/test/test_prototypes.py =================================================================== --- Lib/ctypes/test/test_prototypes.py (revision 62102) +++ Lib/ctypes/test/test_prototypes.py (working copy) @@ -57,7 +57,7 @@ try: func() - except TypeError as details: + except TypeError, details: self.failUnlessEqual(str(details), "required argument 'input' missing") else: self.fail("TypeError not raised") Index: Modules/_ctypes/_ctypes.c =================================================================== --- Modules/_ctypes/_ctypes.c (revision 62102) +++ Modules/_ctypes/_ctypes.c (working copy) @@ -139,6 +139,34 @@ /****************************************************************/ +#if (PY_VERSION_HEX < 0x02040000) +/* Only in Python 2.4 and up */ +static PyObject * +PyTuple_Pack(int n, ...) +{ + int i; + PyObject *o; + PyObject *result; + PyObject **items; + va_list vargs; + + va_start(vargs, n); + result = PyTuple_New(n); + if (result == NULL) + return NULL; + items = ((PyTupleObject *)result)->ob_item; + for (i = 0; i < n; i++) { + o = va_arg(vargs, PyObject *); + Py_INCREF(o); + items[i] = o; + } + va_end(vargs); + return result; +} +#endif + +/****************************************************************/ + typedef struct { PyObject_HEAD PyObject *key; @@ -4432,32 +4460,6 @@ (inquiry)Simple_nonzero, /* nb_nonzero */ }; -#if (PY_VERSION_HEX < 0x02040000) -/* Only in Python 2.4 and up */ -static PyObject * -PyTuple_Pack(int n, ...) -{ - int i; - PyObject *o; - PyObject *result; - PyObject **items; - va_list vargs; - - va_start(vargs, n); - result = PyTuple_New(n); - if (result == NULL) - return NULL; - items = ((PyTupleObject *)result)->ob_item; - for (i = 0; i < n; i++) { - o = va_arg(vargs, PyObject *); - Py_INCREF(o); - items[i] = o; - } - va_end(vargs); - return result; -} -#endif - /* "%s(%s)" % (self.__class__.__name__, self.value) */ static PyObject * Simple_repr(CDataObject *self) Index: Modules/_ctypes/ctypes.h =================================================================== --- Modules/_ctypes/ctypes.h (revision 62102) +++ Modules/_ctypes/ctypes.h (working copy) @@ -9,8 +9,18 @@ #if (PY_VERSION_HEX < 0x02050000) typedef int Py_ssize_t; #define PyInt_FromSsize_t PyInt_FromLong +#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob) #endif +#if (PY_VERSION_HEX < 0x02060000) +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) +#define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, +#define PyImport_ImportModuleNoBlock PyImport_ImportModule +#define PyIndex_Check(ob) PyInt_Check(ob) +#endif + + #ifndef MS_WIN32 #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))