Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r477:f4b5c451867f Date: 2012-06-20 17:04 +0200 http://bitbucket.org/cffi/cffi/changeset/f4b5c451867f/
Log: - Turn Py_FatalError() into raising SystemErrors. - Fix the issue with callbacks returning 'void'. diff --git a/c/_ffi_backend.c b/c/_ffi_backend.c --- a/c/_ffi_backend.c +++ b/c/_ffi_backend.c @@ -593,8 +593,8 @@ return PyString_FromStringAndSize(data, 1); } - fprintf(stderr, "convert_to_object: '%s'\n", ct->ct_name); - Py_FatalError("convert_to_object"); + PyErr_Format(PyExc_SystemError, + "convert_to_object: '%s'", ct->ct_name); return NULL; } @@ -870,8 +870,8 @@ return -1; return convert_from_object(data, cf->cf_type, init); } - fprintf(stderr, "convert_from_object: '%s'\n", ct->ct_name); - Py_FatalError("convert_from_object"); + PyErr_Format(PyExc_SystemError, + "convert_from_object: '%s'", ct->ct_name); return -1; overflow: @@ -3030,8 +3030,9 @@ if (py_res == NULL) goto error; - if (convert_from_object(result, SIGNATURE(0), py_res) < 0) - goto error; + if (SIGNATURE(0)->ct_size > 0) + if (convert_from_object(result, SIGNATURE(0), py_res) < 0) + goto error; done: Py_XDECREF(py_args); Py_XDECREF(py_res); @@ -3041,7 +3042,8 @@ error: PyErr_WriteUnraisable(py_ob); - memset(result, 0, SIGNATURE(0)->ct_size); + if (SIGNATURE(0)->ct_size > 0) + memset(result, 0, SIGNATURE(0)->ct_size); goto done; } diff --git a/testing/backend_tests.py b/testing/backend_tests.py --- a/testing/backend_tests.py +++ b/testing/backend_tests.py @@ -588,6 +588,14 @@ assert repr(res) == "<cdata 'int *'>" assert ffi.cast("long", res) != 0 + def test_functionptr_void_return(self): + ffi = FFI(backend=self.Backend()) + def foo(): + pass + foo_cb = ffi.callback("void foo()", foo) + result = foo_cb() + assert result is None + def test_char_cast(self): ffi = FFI(backend=self.Backend()) p = ffi.cast("int", '\x01') _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit