Commits

Armin Rigo committed c255068 Merge

Merged in pjenvey/cffi (pull request #13)

Comments (0)

Files changed (3)

         if key in ffi._parser._declarations:
             tp = ffi._parser._declarations[key]
             BType = ffi._get_cached_btype(tp)
-            value = backendlib.load_function(BType, name)
+            try:
+                value = backendlib.load_function(BType, name)
+            except KeyError:
+                raise AttributeError(name)
             library.__dict__[name] = value
             return
         #

testing/test_function.py

         lib = ffi.dlopen(None)
         res = lib.strlen(b"hello")
         assert res == 5
+
+    def test_missing_function(self):
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("""
+            int nonexistent();
+        """)
+        m = ffi.dlopen("m")
+        assert not hasattr(m, 'nonexistent')

testing/test_verify.py

 if sys.platform == 'win32':
     pass      # no obvious -Werror equivalent on MSVC
 elif (sys.platform == 'darwin' and
-      map(int, os.uname()[2].split('.')) >= [11, 0, 0]):
+      [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
     pass      # recent MacOSX come with clang by default, and passing some
               # flags from the interpreter (-mno-fused-madd) generates a
               # warning --- which is interpreted as an error with -Werror