Author: Armin Rigo <[email protected]>
Branch: cffi-1.0
Changeset: r1195:2c7a859bc43a
Date: 2013-03-08 13:56 +0100
http://bitbucket.org/cffi/cffi/changeset/2c7a859bc43a/

Log:    merge heads

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -1,4 +1,4 @@
-import types
+import types, warnings
 
 try:
     callable
@@ -233,7 +233,7 @@
         """
         return self._backend.buffer(cdata, size)
 
-    def callback(self, cdecl, error=None):
+    def callback(self, cdecl, python_callable=None, error=None):
         """Return a a decorator making a callback object.  'cdecl' must
         name a C function or function pointer type.  The decorated
         Python function is turned into a <cdata> of the specified
@@ -248,9 +248,10 @@
             return self._backend.callback(cdecl, python_callable, error)
         if isinstance(cdecl, basestring):
             cdecl = self._typeof(cdecl, consider_function_as_funcptr=True)
-        if isinstance(error, types.FunctionType):
-            raise TypeError("Not supported any more: ffi.callback('...', fn)."
-                            " Use the decorator form: @ffi.callback('...')")
+        if python_callable is not None:
+            warnings.warn("Not supported any more: ffi.callback('...', fn)."
+                          " Use the decorator form: @ffi.callback('...')")
+            return callback_decorator_wrap(python_callable)
         return callback_decorator_wrap
 
     def getctype(self, cdecl, replace_with=''):
diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -811,6 +811,7 @@
         res = a(1)    # and the error reported to stderr
         assert res == 42
         #
+        py.test.skip("this is deprecated, not removed yet")
         @ffi.callback("int(int)", 46)
         def a(n):
             raise Exception
@@ -1272,6 +1273,7 @@
         sz = ffi.sizeof("long")
         assert cb((1 << (sz*8-1)) - 1, -10) == 42
         #
+        py.test.skip("Deprecated, not removed")
         py.test.raises(TypeError, ffi.callback, "int(int)", lambda n: n+1)
         py.test.raises(TypeError, ffi.callback, "int(int)", lambda n: n+1,
                        error=42)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to