[Python-checkins] r55832 - python/trunk/Modules/_ctypes/_ctypes.c python/trunk/Modules/_ctypes/cfield.c python/trunk/Modules/_ctypes/stgdict.c

thomas.heller python-checkins at python.org
Fri Jun 8 21:01:10 CEST 2007


Author: thomas.heller
Date: Fri Jun  8 21:01:06 2007
New Revision: 55832

Modified:
   python/trunk/Modules/_ctypes/_ctypes.c
   python/trunk/Modules/_ctypes/cfield.c
   python/trunk/Modules/_ctypes/stgdict.c
Log:
Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls.

Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c	(original)
+++ python/trunk/Modules/_ctypes/_ctypes.c	Fri Jun  8 21:01:06 2007
@@ -1769,7 +1769,12 @@
 	Py_XDECREF(converters);
 	Py_DECREF(ob);
 	PyErr_Format(PyExc_TypeError,
-		     "item %d in _argtypes_ has no from_param method", i+1);
+#if (PY_VERSION_HEX < 0x02050000)
+		     "item %d in _argtypes_ has no from_param method",
+#else
+		     "item %zd in _argtypes_ has no from_param method",
+#endif
+		     i+1);
 	return NULL;
 }
 
@@ -3191,7 +3196,11 @@
 		   message is misleading.  See unittests/test_paramflags.py
 		 */
 		PyErr_Format(PyExc_TypeError,
+#if (PY_VERSION_HEX < 0x02050000)
 			     "call takes exactly %d arguments (%d given)",
+#else
+			     "call takes exactly %d arguments (%zd given)",
+#endif
 			     inargs_index, actual_args);
 		goto error;
 	}

Modified: python/trunk/Modules/_ctypes/cfield.c
==============================================================================
--- python/trunk/Modules/_ctypes/cfield.c	(original)
+++ python/trunk/Modules/_ctypes/cfield.c	Fri Jun  8 21:01:06 2007
@@ -220,21 +220,13 @@
 static PyObject *
 CField_get_offset(PyObject *self, void *data)
 {
-#if (PY_VERSION_HEX < 0x02050000)
-	return PyInt_FromLong(((CFieldObject *)self)->offset);
-#else
 	return PyInt_FromSsize_t(((CFieldObject *)self)->offset);
-#endif
 }
 
 static PyObject *
 CField_get_size(PyObject *self, void *data)
 {
-#if (PY_VERSION_HEX < 0x02050000)
-	return PyInt_FromLong(((CFieldObject *)self)->size);
-#else
 	return PyInt_FromSsize_t(((CFieldObject *)self)->size);
-#endif
 }
 
 static PyGetSetDef CField_getset[] = {
@@ -279,7 +271,7 @@
 #if (PY_VERSION_HEX < 0x02050000)
 			"<Field type=%s, ofs=%d:%d, bits=%d>",
 #else
-			"<Field type=%s, ofs=%zd:%d, bits=%d>",
+			"<Field type=%s, ofs=%zd:%zd, bits=%zd>",
 #endif
 			name, self->offset, size, bits);
 	else
@@ -287,7 +279,7 @@
 #if (PY_VERSION_HEX < 0x02050000)
 			"<Field type=%s, ofs=%d, size=%d>",
 #else
-			"<Field type=%s, ofs=%zd, size=%d>",
+			"<Field type=%s, ofs=%zd, size=%zd>",
 #endif
 			name, self->offset, size);
 	return result;
@@ -1263,7 +1255,11 @@
 	size = PyUnicode_GET_SIZE(value);
 	if (size > length) {
 		PyErr_Format(PyExc_ValueError,
+#if (PY_VERSION_HEX < 0x02050000)
 			     "string too long (%d, maximum length %d)",
+#else
+			     "string too long (%zd, maximum length %zd)",
+#endif
 			     size, length);
 		Py_DECREF(value);
 		return NULL;
@@ -1316,7 +1312,11 @@
 		++size;
 	} else if (size > length) {
 		PyErr_Format(PyExc_ValueError,
+#if (PY_VERSION_HEX < 0x02050000)
 			     "string too long (%d, maximum length %d)",
+#else
+			     "string too long (%zd, maximum length %zd)",
+#endif
 			     size, length);
 		return NULL;
 	}

Modified: python/trunk/Modules/_ctypes/stgdict.c
==============================================================================
--- python/trunk/Modules/_ctypes/stgdict.c	(original)
+++ python/trunk/Modules/_ctypes/stgdict.c	Fri Jun  8 21:01:06 2007
@@ -406,7 +406,11 @@
 		if (dict == NULL) {
 			Py_DECREF(pair);
 			PyErr_Format(PyExc_TypeError,
+#if (PY_VERSION_HEX < 0x02050000)
 				     "second item in _fields_ tuple (index %d) must be a C type",
+#else
+				     "second item in _fields_ tuple (index %zd) must be a C type",
+#endif
 				     i);
 			return -1;
 		}


More information about the Python-checkins mailing list