[Python-checkins] r51274 - python/trunk/Modules/_ctypes/callbacks.c
thomas.heller
python-checkins at python.org
Mon Aug 14 12:02:24 CEST 2006
Author: thomas.heller
Date: Mon Aug 14 12:02:24 2006
New Revision: 51274
Modified:
python/trunk/Modules/_ctypes/callbacks.c
Log:
Revert the change that tries to zero out a closure's result storage
area because the size if unknown in source/callproc.c.
Modified: python/trunk/Modules/_ctypes/callbacks.c
==============================================================================
--- python/trunk/Modules/_ctypes/callbacks.c (original)
+++ python/trunk/Modules/_ctypes/callbacks.c Mon Aug 14 12:02:24 2006
@@ -205,24 +205,14 @@
result = PyObject_CallObject(callable, arglist);
CHECK("'calling callback function'", result);
-#ifdef WORDS_BIGENDIAN
- /* See the corresponding code in callproc.c, around line 961 */
- if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg))
- mem = (char *)mem + sizeof(ffi_arg) - restype->size;
-#endif
- /* The code that converts 'result' into C data is not executed when
- 'callable' returns Py_None, so we zero out the memory that will
- receive the C return data to not return random data.
-
- Cleaner would be to call 'setfunc' anyway and complain with
- PyErr_WriteUnraisable(), but ctypes has always accepted a Py_None
- return value for *any* 'restype' and it would probably break too
- much code if this is changed now.
- */
- memset(mem, 0, restype->size);
if ((restype != &ffi_type_void) && result && result != Py_None) {
PyObject *keep;
assert(setfunc);
+#ifdef WORDS_BIGENDIAN
+ /* See the corresponding code in callproc.c, around line 961 */
+ if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg))
+ mem = (char *)mem + sizeof(ffi_arg) - restype->size;
+#endif
keep = setfunc(mem, result, 0);
CHECK("'converting callback result'", keep);
/* keep is an object we have to keep alive so that the result
More information about the Python-checkins
mailing list