[pypy-commit] pypy default: Update to cffi c42e0c485fc8.
arigo
noreply at buildbot.pypy.org
Fri Feb 8 18:37:10 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r60987:e2ea2eb4743c
Date: 2013-02-08 10:16 +0100
http://bitbucket.org/pypy/pypy/changeset/e2ea2eb4743c/
Log: Update to cffi c42e0c485fc8.
diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -252,7 +252,10 @@
def _prepare_pointer_call_argument(self, w_init, cdata):
space = self.space
- if (space.isinstance_w(w_init, space.w_list) or
+ if space.is_w(w_init, space.w_None):
+ rffi.cast(rffi.CCHARPP, cdata)[0] = lltype.nullptr(rffi.CCHARP.TO)
+ return 3
+ elif (space.isinstance_w(w_init, space.w_list) or
space.isinstance_w(w_init, space.w_tuple)):
length = space.int_w(space.len(w_init))
elif space.isinstance_w(w_init, space.w_basestring):
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
@@ -998,6 +998,8 @@
f = cast(BFunc23, _testfunc(23))
res = f(b"foo")
assert res == 1000 * ord(b'f')
+ res = f(None)
+ assert res == -42
def test_call_function_23_bis():
# declaring the function as int(unsigned char*)
diff --git a/pypy/module/_cffi_backend/test/_test_lib.c b/pypy/module/_cffi_backend/test/_test_lib.c
--- a/pypy/module/_cffi_backend/test/_test_lib.c
+++ b/pypy/module/_cffi_backend/test/_test_lib.c
@@ -174,7 +174,9 @@
static int _testfunc23(char *p)
{
- return 1000 * p[0];
+ if (p)
+ return 1000 * p[0];
+ return -42;
}
DLLEXPORT void *gettestfunc(int num)
More information about the pypy-commit
mailing list