Author: Philip Jenvey <[email protected]>
Branch:
Changeset: r63710:c4ecb23cac56
Date: 2013-04-27 15:02 -0700
http://bitbucket.org/pypy/pypy/changeset/c4ecb23cac56/
Log: apply e2b9db908b90 from upstream: fix handling w/ py3 hasattr, which
only swallows AttributeErrors
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/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/pypy/module/test_lib_pypy/cffi_tests/test_function.py
b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_function.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
@@ -333,3 +333,11 @@
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')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit