[pypy-commit] pypy cffi-1.0: Update to cffi/2d4469c2fec5

arigo noreply at buildbot.pypy.org
Mon May 18 17:43:43 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r77374:fd3f5bfeb3b8
Date: 2015-05-18 17:43 +0200
http://bitbucket.org/pypy/pypy/changeset/fd3f5bfeb3b8/

Log:	Update to cffi/2d4469c2fec5

diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -10,7 +10,7 @@
     ENUM_S, TYPENAME_S, ll_set_cdl_realize_global_int)
 from pypy.module._cffi_backend.realize_c_type import getop
 from pypy.module._cffi_backend.lib_obj import W_LibObject
-from pypy.module._cffi_backend import cffi_opcode
+from pypy.module._cffi_backend import cffi_opcode, cffi1_module
 
 
 class W_DlOpenLibObject(W_LibObject):
@@ -118,6 +118,13 @@
     # otherwise ll2ctypes explodes.  I don't want to know :-(
     rffi.cast(lltype.Signed, ffi.ctxobj)
 
+    if version == -1 and not types:
+        return
+    if not (cffi1_module.VERSION_MIN <= version <= cffi1_module.VERSION_MAX):
+        raise oefmt(space.w_ImportError,
+            "cffi out-of-line Python module '%s' has unknown version %s",
+            module_name, hex(version))
+
     if types:
         # unpack a string of 4-byte entries into an array of _cffi_opcode_t
         n = len(types) // 4
diff --git a/pypy/module/_cffi_backend/ffi_obj.py b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -155,8 +155,8 @@
                     m1, s12, m2, s23, m3, w_x)
 
 
-    @unwrap_spec(module_name="str_or_None", _version=int, _types="str_or_None")
-    def descr_init(self, module_name=None, _version=-1, _types=None,
+    @unwrap_spec(module_name=str, _version=int, _types=str)
+    def descr_init(self, module_name='?', _version=-1, _types='',
                    w__globals=None, w__struct_unions=None, w__enums=None,
                    w__typenames=None, w__includes=None):
         from pypy.module._cffi_backend import cdlopen
diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -172,3 +172,10 @@
         e = raises(ffi.error, getattr, lib, 'no_such_globalvar')
         assert str(e.value).startswith(
             "symbol 'no_such_globalvar' not found in library '")
+
+    def test_check_version(self):
+        import _cffi_backend
+        e = raises(ImportError, _cffi_backend.FFI,
+            "foobar", _version=0x2594)
+        assert str(e.value).startswith(
+            "cffi out-of-line Python module 'foobar' has unknown version")


More information about the pypy-commit mailing list