[pypy-commit] cffi default: Merged in pjenvey/cffi (pull request #13)

arigo noreply at buildbot.pypy.org
Sat Apr 6 12:37:01 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1242:c2550687121c
Date: 2013-04-06 12:35 +0200
http://bitbucket.org/cffi/cffi/changeset/c2550687121c/

Log:	Merged in pjenvey/cffi (pull request #13)

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -370,7 +370,10 @@
         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
         #
diff --git a/testing/test_function.py b/testing/test_function.py
--- a/testing/test_function.py
+++ b/testing/test_function.py
@@ -370,3 +370,11 @@
         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')
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -7,7 +7,7 @@
 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


More information about the pypy-commit mailing list