of the Python part of a callback function to C. If it cannot be
converted, call PyErr_WriteUnraisable with the exception we got.
Before, arbitrary data has been passed to the calling C code in this
case.
(I'm not really sure the NEWS entry is understandable, but I cannot
find better words)
def callback(v):
args.append(v)
+ return v
CallBack = CFUNCTYPE(c_int, c_int)
def callback(v):
args.append(v)
+ return v
CallBack = CFUNCTYPE(c_int, c_int)
Library
-------
+- If a the Python part of a ctypes callback function returns None,
+ and this cannot be converted to the required C type, an exception is
+ printed with PyErr_WriteUnraisable. Before this change, the C
+ callback did return arbitrary values to the calling code.
+
- The __repr__ method of a NULL ctypes.py_object() no longer raises
an exception.
result = PyObject_CallObject(callable, arglist);
CHECK("'calling callback function'", result);
- if ((restype != &ffi_type_void) && result && result != Py_None) {
+ if ((restype != &ffi_type_void) && result) {
PyObject *keep;
assert(setfunc);
#ifdef WORDS_BIGENDIAN