[pypy-commit] pypy ffi-backend: Fix for test_load_and_call_function.
arigo
noreply at buildbot.pypy.org
Thu Jul 26 13:11:13 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r56469:6e47dd6cea00
Date: 2012-07-26 13:10 +0200
http://bitbucket.org/pypy/pypy/changeset/6e47dd6cea00/
Log: Fix for test_load_and_call_function.
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
@@ -9,7 +9,6 @@
from pypy.module._cffi_backend.cdataobj import W_CData
from pypy.module._cffi_backend.ctypeobj import W_CType
-from pypy.module._cffi_backend.ctypefunc import W_CTypeFunc
class W_Library(Wrappable):
@@ -40,15 +39,28 @@
space = self.space
return space.wrap("<clibrary '%s'>" % self.name)
- @unwrap_spec(ctypefunc=W_CTypeFunc, name=str)
- def load_function(self, ctypefunc, name):
+ @unwrap_spec(ctype=W_CType, name=str)
+ def load_function(self, ctype, name):
+ from pypy.module._cffi_backend import ctypefunc, ctypeptr, ctypevoid
space = self.space
+ #
+ ok = False
+ if isinstance(ctype, ctypefunc.W_CTypeFunc):
+ ok = True
+ if (isinstance(ctype, ctypeptr.W_CTypePointer) and
+ isinstance(ctype.ctitem, ctypevoid.W_CTypeVoid)):
+ ok = True
+ if not ok:
+ raise operationerrfmt(space.w_TypeError,
+ "function cdata expected, got '%s'",
+ ctype.name)
+ #
cdata = dlsym(self.handle, name)
if not cdata:
raise operationerrfmt(space.w_KeyError,
"function '%s' not found in library '%s'",
name, self.name)
- return W_CData(space, rffi.cast(rffi.CCHARP, cdata), ctypefunc)
+ return W_CData(space, rffi.cast(rffi.CCHARP, cdata), ctype)
@unwrap_spec(ctype=W_CType, name=str)
def read_variable(self, ctype, name):
More information about the pypy-commit
mailing list