[pypy-commit] cffi default: Test and fix.

arigo noreply at buildbot.pypy.org
Sat Jun 16 11:35:21 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r392:afc6e0b7234b
Date: 2012-06-16 11:35 +0200
http://bitbucket.org/cffi/cffi/changeset/afc6e0b7234b/

Log:	Test and fix.

diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py
--- a/cffi/backend_ctypes.py
+++ b/cffi/backend_ctypes.py
@@ -647,7 +647,7 @@
         #
         class CTypesFunction(CTypesGenericPtr):
             __slots__ = ['_own_callback', '_name']
-            _ctype = ctypes.CFUNCTYPE(BResult._ctype,
+            _ctype = ctypes.CFUNCTYPE(getattr(BResult, '_ctype', None),
                                       *[BArg._ctype for BArg in BArgs],
                                       use_errno=True)
             _reftypename = BResult._get_c_name('(* &)(%s)' % (nameargs,))
diff --git a/testing/test_function.py b/testing/test_function.py
--- a/testing/test_function.py
+++ b/testing/test_function.py
@@ -53,6 +53,16 @@
         assert x != math.sin(1.23)    # rounding effects
         assert abs(x - math.sin(1.23)) < 1E-6
 
+    def test_sin_no_return_value(self):
+        # check that 'void'-returning functions work too
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("""
+            void sin(double x);
+        """)
+        m = ffi.dlopen("m")
+        x = m.sin(1.23)
+        assert x is None
+
     def test_tlsalloc(self):
         if sys.platform != 'win32':
             py.test.skip("win32 only")


More information about the pypy-commit mailing list