[pypy-commit] cffi default: Test and explicit exception in case we call verify() with the ctypes
arigo
noreply at buildbot.pypy.org
Fri Jun 15 23:54:11 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r381:9f6d56f9bce5
Date: 2012-06-15 23:54 +0200
http://bitbucket.org/cffi/cffi/changeset/9f6d56f9bce5/
Log: Test and explicit exception in case we call verify() with the ctypes
backend (instead of the C code getting confused and crashing
obscurely).
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -24,6 +24,11 @@
an instance. Finally, we copy all the API elements from
the module to the class or the instance as needed.
"""
+ import _ffi_backend
+ if self.ffi._backend is not _ffi_backend:
+ raise NotImplementedError(
+ "verify() is only available for the _ffi_backend")
+
modname = ffiplatform.undercffi_module_name()
tmpdir = ffiplatform.tmpdir()
filebase = os.path.join(tmpdir, modname)
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -429,3 +429,9 @@
my_callback = ffi.callback("int(*)(int)", lambda n: n * 222)
lib.cb = my_callback
assert lib.foo(4) == 887
+
+def test_cannot_verify_with_ctypes():
+ from cffi.backend_ctypes import CTypesBackend
+ ffi = FFI(backend=CTypesBackend())
+ ffi.cdef("int a;")
+ py.test.raises(NotImplementedError, ffi.verify, "int a;")
More information about the pypy-commit
mailing list