Author: Armin Rigo <[email protected]>
Branch:
Changeset: r60988:ca1b566f9dea
Date: 2013-02-08 18:36 +0100
http://bitbucket.org/pypy/pypy/changeset/ca1b566f9dea/
Log: merge heads
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)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit