Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r508:dd6230e7ea2e
Date: 2012-06-25 12:20 +0200
http://bitbucket.org/cffi/cffi/changeset/dd6230e7ea2e/

Log:    A convenient way to change the default return value of 0 in case the
        callback crashes.

diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -655,6 +655,15 @@
         assert a == b
         assert hash(a) == hash(b)
 
+    def test_callback_crash(self):
+        py.test.skip("in-progress")
+        ffi = FFI(backend=self.Backend())
+        def cb(n):
+            raise Exception
+        a = ffi.callback("int(*)(int)", cb, error=42)
+        res = a(1)    # and the error reported to stderr
+        assert res == 42
+
     def test_cast_float(self):
         ffi = FFI(backend=self.Backend())
         a = ffi.cast("float", 12)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to