Commits

Philip Jenvey  committed e2b9db9

fix handling w/ py3 hasattr, which only swallows AttributeErrors

  • Participants
  • Parent commits 95eb111

Comments (0)

Files changed (2)

         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
         #

File testing/test_function.py

         assert lib.DD == 6
         assert lib.EE == -5
         assert lib.FF == -4
+
+    def test_missing_function(self):
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("""
+            int nonexistent();
+        """)
+        m = ffi.dlopen("m")
+        assert not hasattr(m, 'nonexistent')