[pypy-commit] pypy default: Import cffi's 713b2badd33b and fix
arigo
noreply at buildbot.pypy.org
Tue Jun 9 20:51:10 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r77999:7959ab6b0b35
Date: 2015-06-09 20:51 +0200
http://bitbucket.org/pypy/pypy/changeset/7959ab6b0b35/
Log: Import cffi's 713b2badd33b and fix
diff --git a/pypy/module/_cffi_backend/lib_obj.py b/pypy/module/_cffi_backend/lib_obj.py
--- a/pypy/module/_cffi_backend/lib_obj.py
+++ b/pypy/module/_cffi_backend/lib_obj.py
@@ -65,7 +65,7 @@
ptr = rffi.cast(rffi.CCHARP, g.c_address)
assert ptr
return W_FunctionWrapper(self.space, ptr, g.c_size_or_direct_fn, w_ct,
- locs, rawfunctype, fnname)
+ locs, rawfunctype, fnname, self.libname)
@jit.elidable_promote()
def _get_attr_elidable(self, attr):
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -418,6 +418,11 @@
# 'x' is another <built-in method> object on lib, made very indirectly
x = type(lib).__dir__.__get__(lib)
raises(TypeError, ffi.typeof, x)
+ #
+ # present on built-in functions on CPython; must be emulated on PyPy:
+ assert lib.sin.__name__ == 'sin'
+ assert lib.sin.__module__ == '_CFFI_test_math_sin_type'
+ assert lib.sin.__doc__=='direct call to the C function of the same name'
def test_verify_anonymous_struct_with_typedef(self):
ffi, lib = self.prepare(
diff --git a/pypy/module/_cffi_backend/wrapper.py b/pypy/module/_cffi_backend/wrapper.py
--- a/pypy/module/_cffi_backend/wrapper.py
+++ b/pypy/module/_cffi_backend/wrapper.py
@@ -1,6 +1,6 @@
from pypy.interpreter.error import oefmt
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.gateway import interp2app
from rpython.rlib import jit
@@ -21,9 +21,10 @@
also returns the original struct/union signature.
"""
_immutable_ = True
+ common_doc_str = 'direct call to the C function of the same name'
def __init__(self, space, fnptr, directfnptr, ctype,
- locs, rawfunctype, fnname):
+ locs, rawfunctype, fnname, modulename):
assert isinstance(ctype, W_CTypeFunc)
assert ctype.cif_descr is not None # not for '...' functions
assert locs is None or len(ctype.fargs) == len(locs)
@@ -35,6 +36,7 @@
self.locs = locs
self.rawfunctype = rawfunctype
self.fnname = fnname
+ self.modulename = modulename
self.nargs_expected = len(ctype.fargs) - (locs is not None and
locs[0] == 'R')
@@ -111,5 +113,8 @@
'FFIFunctionWrapper',
__repr__ = interp2app(W_FunctionWrapper.descr_repr),
__call__ = interp2app(W_FunctionWrapper.descr_call),
+ __name__ = interp_attrproperty('fnname', cls=W_FunctionWrapper),
+ __module__ = interp_attrproperty('modulename', cls=W_FunctionWrapper),
+ __doc__ = interp_attrproperty('common_doc_str', cls=W_FunctionWrapper),
)
W_FunctionWrapper.typedef.acceptable_as_base_class = False
More information about the pypy-commit
mailing list