[pypy-svn] r79697 - in pypy/branch/jitypes2/pypy/module/_ffi: . test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Nov 30 18:39:09 CET 2010
Author: antocuni
Date: Tue Nov 30 18:39:08 2010
New Revision: 79697
Modified:
pypy/branch/jitypes2/pypy/module/_ffi/interp_ffi.py
pypy/branch/jitypes2/pypy/module/_ffi/test/test__ffi.py
Log:
raise an applevel AttributeError when trying to get a pointer to a non existent function
Modified: pypy/branch/jitypes2/pypy/module/_ffi/interp_ffi.py
==============================================================================
--- pypy/branch/jitypes2/pypy/module/_ffi/interp_ffi.py (original)
+++ pypy/branch/jitypes2/pypy/module/_ffi/interp_ffi.py Tue Nov 30 18:39:08 2010
@@ -192,7 +192,12 @@
argtypes = [self.ffitype(w_argtype) for w_argtype in
space.listview(w_argtypes)]
restype = self.ffitype(w_restype, allow_void=True)
- func = self.cdll.getpointer(name, argtypes, restype)
+ try:
+ func = self.cdll.getpointer(name, argtypes, restype)
+ except KeyError:
+ raise operationerrfmt(space.w_AttributeError,
+ "No symbol %s found in library %s", name, self.name)
+
return W_FuncPtr(func)
Modified: pypy/branch/jitypes2/pypy/module/_ffi/test/test__ffi.py
==============================================================================
--- pypy/branch/jitypes2/pypy/module/_ffi/test/test__ffi.py (original)
+++ pypy/branch/jitypes2/pypy/module/_ffi/test/test__ffi.py Tue Nov 30 18:39:08 2010
@@ -142,3 +142,8 @@
def test_OSError_loading(self):
from _ffi import CDLL, types
raises(OSError, "CDLL('I do not exist')")
+
+ def test_AttributeError_missing_function(self):
+ from _ffi import CDLL, types
+ libfoo = CDLL(self.libfoo_name)
+ raises(AttributeError, "libfoo.getfunc('I_do_not_exist', [], types.void)")
More information about the Pypy-commit
mailing list