Author: Armin Rigo <[email protected]>
Branch:
Changeset: r90001:f63a701a6ae4
Date: 2017-02-07 16:36 +0100
http://bitbucket.org/pypy/pypy/changeset/f63a701a6ae4/
Log: update to cffi/6f5001375739
diff --git a/pypy/module/_cffi_backend/libraryobj.py
b/pypy/module/_cffi_backend/libraryobj.py
--- a/pypy/module/_cffi_backend/libraryobj.py
+++ b/pypy/module/_cffi_backend/libraryobj.py
@@ -40,25 +40,22 @@
@unwrap_spec(w_ctype=W_CType, name=str)
def load_function(self, w_ctype, name):
- from pypy.module._cffi_backend import ctypefunc, ctypeptr, ctypevoid
+ from pypy.module._cffi_backend import ctypeptr, ctypearray
space = self.space
#
- ok = False
- if isinstance(w_ctype, ctypefunc.W_CTypeFunc):
- ok = True
- if (isinstance(w_ctype, ctypeptr.W_CTypePointer) and
- isinstance(w_ctype.ctitem, ctypevoid.W_CTypeVoid)):
- ok = True
- if not ok:
+ if not isinstance(w_ctype, ctypeptr.W_CTypePtrOrArray):
raise oefmt(space.w_TypeError,
- "function cdata expected, got '%s'", w_ctype.name)
+ "function or pointer or array cdata expected, got
'%s'",
+ w_ctype.name)
#
try:
cdata = dlsym(self.handle, name)
except KeyError:
- raise oefmt(space.w_KeyError,
- "function '%s' not found in library '%s'",
+ raise oefmt(space.w_AttributeError,
+ "function/symbol '%s' not found in library '%s'",
name, self.name)
+ if isinstance(w_ctype, ctypearray.W_CTypeArray) and w_ctype.length < 0:
+ w_ctype = w_ctype.ctptr
return W_CData(space, rffi.cast(rffi.CCHARP, cdata), w_ctype)
@unwrap_spec(w_ctype=W_CType, name=str)
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -365,7 +365,7 @@
x = find_and_load_library(None)
BVoidP = new_pointer_type(new_void_type())
assert x.load_function(BVoidP, 'strcpy')
- py.test.raises(KeyError, x.load_function,
+ py.test.raises(AttributeError, x.load_function,
BVoidP, 'xxx_this_function_does_not_exist')
# the next one is from 'libm', not 'libc', but we assume
# that it is already loaded too, so it should work
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit