diff options
author | Thomas Heller <theller@ctypes.org> | 2006-08-14 10:02:24 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2006-08-14 10:02:24 (GMT) |
commit | e6dd31c50be76a5b57917226e16bdaa6ca20a28f (patch) | |
tree | e74d6fe1fca71dc5d495b2d6f6f82b9b9431f689 | |
parent | dca703fbda6d96e97e3872796c1748ee1b6a08e6 (diff) | |
download | cpython-e6dd31c50be76a5b57917226e16bdaa6ca20a28f.zip cpython-e6dd31c50be76a5b57917226e16bdaa6ca20a28f.tar.gz cpython-e6dd31c50be76a5b57917226e16bdaa6ca20a28f.tar.bz2 |
Revert the change that tries to zero out a closure's result storage
area because the size if unknown in source/callproc.c.
-rw-r--r-- | Modules/_ctypes/callbacks.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 3ad6fb4..cbe3d03 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -205,24 +205,14 @@ if (x == NULL) _AddTraceback(what, __FILE__, __LINE__ - 1), PyErr_Print() 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 |