[Python-checkins] r43053 - python/trunk/Modules/_ctypes/_ctypes.c python/trunk/Modules/_ctypes/cfield.c python/trunk/Modules/_ctypes/ctypes.h
thomas.heller
python-checkins at python.org
Wed Mar 15 22:49:56 CET 2006
Author: thomas.heller
Date: Wed Mar 15 22:49:52 2006
New Revision: 43053
Modified:
python/trunk/Modules/_ctypes/_ctypes.c
python/trunk/Modules/_ctypes/cfield.c
python/trunk/Modules/_ctypes/ctypes.h
Log:
Backport from upstream version: compatibility with older Python
versions.
Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c (original)
+++ python/trunk/Modules/_ctypes/_ctypes.c Wed Mar 15 22:49:52 2006
@@ -3674,7 +3674,11 @@
if (cache == NULL)
return NULL;
}
+#if (PY_VERSION_HEX < 0x02050000)
+ key = Py_BuildValue("(Oi)", itemtype, length);
+#else
key = Py_BuildValue("(On)", itemtype, length);
+#endif
if (!key)
return NULL;
result = PyDict_GetItem(cache, key);
@@ -3698,7 +3702,11 @@
#endif
result = PyObject_CallFunction((PyObject *)&ArrayType_Type,
+#if (PY_VERSION_HEX < 0x02050000)
+ "s(O){s:i,s:O}",
+#else
"s(O){s:n,s:O}",
+#endif
name,
&Array_Type,
"_length_",
Modified: python/trunk/Modules/_ctypes/cfield.c
==============================================================================
--- python/trunk/Modules/_ctypes/cfield.c (original)
+++ python/trunk/Modules/_ctypes/cfield.c Wed Mar 15 22:49:52 2006
@@ -250,11 +250,21 @@
name = ((PyTypeObject *)self->proto)->tp_name;
if (bits)
- result = PyString_FromFormat("<Field type=%s, ofs=%d:%d, bits=%d>",
- name, (int)self->offset, size, bits);
+ result = PyString_FromFormat(
+#if (PY_VERSION_HEX < 0x02050000)
+ "<Field type=%s, ofs=%d:%d, bits=%d>",
+#else
+ "<Field type=%s, ofs=%zd:%d, bits=%d>",
+#endif
+ name, self->offset, size, bits);
else
- result = PyString_FromFormat("<Field type=%s, ofs=%d, size=%d>",
- name, (int)self->offset, size);
+ result = PyString_FromFormat(
+#if (PY_VERSION_HEX < 0x02050000)
+ "<Field type=%s, ofs=%d, size=%d>",
+#else
+ "<Field type=%s, ofs=%zd, size=%d>",
+#endif
+ name, self->offset, size);
return result;
}
Modified: python/trunk/Modules/_ctypes/ctypes.h
==============================================================================
--- python/trunk/Modules/_ctypes/ctypes.h (original)
+++ python/trunk/Modules/_ctypes/ctypes.h Wed Mar 15 22:49:52 2006
@@ -1,5 +1,18 @@
/******************************************************************/
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#define lenfunc inquiry
+#define readbufferproc getreadbufferproc
+#define writebufferproc getwritebufferproc
+#define segcountproc getsegcountproc
+#define charbufferproc getcharbufferproc
+#define ssizeargfunc intargfunc
+#define ssizessizeargfunc intintargfunc
+#define ssizeobjargproc intobjargproc
+#define ssizessizeobjargproc intintobjargproc
+#endif
+
#ifndef MS_WIN32
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
More information about the Python-checkins
mailing list