Author: Armin Rigo <[email protected]>
Branch:
Changeset: r84855:5039c4482729
Date: 2016-06-01 13:02 +0200
http://bitbucket.org/pypy/pypy/changeset/5039c4482729/
Log: Another pydoc hack, needed because FFIWrapperFunction is otherwise
not considered like a function
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
@@ -1784,3 +1784,9 @@
assert ffi.list_types() == (['CFFIb', 'CFFIbb', 'CFFIbbb'],
['CFFIa', 'CFFIcc', 'CFFIccc'],
['CFFIaa', 'CFFIaaa', 'CFFIg'])
+
+ def test_FFIFunctionWrapper(self):
+ ffi, lib = self.prepare("void f(void);", "test_FFIFunctionWrapper",
+ "void f(void) { }")
+ assert lib.f.__get__(42) is lib.f
+ assert lib.f.__get__(42, int) is lib.f
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
@@ -100,6 +100,11 @@
doc = '%s;\n\nCFFI C function from %s.lib' % (doc, self.modulename)
return space.wrap(doc)
+ def descr_get(self, space, w_obj, w_type=None):
+ # never bind anything, but a __get__ is still present so that
+ # pydoc displays useful information (namely, the __repr__)
+ return self
+
@jit.unroll_safe
def prepare_args(space, rawfunctype, args_w, start_index):
@@ -136,5 +141,6 @@
__name__ = interp_attrproperty('fnname', cls=W_FunctionWrapper),
__module__ = interp_attrproperty('modulename', cls=W_FunctionWrapper),
__doc__ = GetSetProperty(W_FunctionWrapper.descr_get_doc),
+ __get__ = interp2app(W_FunctionWrapper.descr_get),
)
W_FunctionWrapper.typedef.acceptable_as_base_class = False
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit