[Python-checkins] r58406 - python/branches/ctypes-branch/Modules/_ctypes/cfield.c

thomas.heller python-checkins at python.org
Wed Oct 10 13:12:38 CEST 2007


Author: thomas.heller
Date: Wed Oct 10 13:12:38 2007
New Revision: 58406

Modified:
   python/branches/ctypes-branch/Modules/_ctypes/cfield.c
Log:
More printing.

Modified: python/branches/ctypes-branch/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/cfield.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/cfield.c	Wed Oct 10 13:12:38 2007
@@ -993,7 +993,7 @@
 D_set(void *ptr, PyObject *value, Py_ssize_t size)
 {
 	long double x;
-
+	int i;
 	x = PyFloat_AsDouble(value);
 	if (x == -1 && PyErr_Occurred()) {
 		PyErr_Format(PyExc_TypeError,
@@ -1001,8 +1001,11 @@
 			     value->ob_type->tp_name);
 		return NULL;
 	}
-	fprintf(stderr, "D_set(%p, %f)\n", ptr, (float)x);
 	memcpy(ptr, &x, sizeof(long double));
+	fprintf(stderr, "D_set(%p, %f) (", ptr, (float)x);
+	for (i = 0; i < sizeof(long double); ++i)
+		fprintf(stderr, "%02x ", ((char *)ptr)[i] & 0xFF);
+	fprintf(stderr, ")\n");
 	_RET(value);
 }
 
@@ -1010,8 +1013,12 @@
 D_get(void *ptr, Py_ssize_t size)
 {
 	long double val;
+	int i;
 	memcpy(&val, ptr, sizeof(long double));
-	fprintf(stderr, "D_get(%p) -> %f\n", ptr, (float)val);
+	fprintf(stderr, "D_get(%p) %f  (", ptr, (float)val);
+	for (i = 0; i < sizeof(long double); ++i)
+		fprintf(stderr, "%02x ", ((char *)ptr)[i] & 0xFF);
+	fprintf(stderr, ")\n");
 	return PyFloat_FromDouble(val);
 }
 


More information about the Python-checkins mailing list