Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1626:c5beb414dbb8
Date: 2015-01-09 11:56 +0100
http://bitbucket.org/cffi/cffi/changeset/c5beb414dbb8/
Log: improve the error message to match pypy's
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4153,9 +4153,10 @@
return ffistruct;
}
else {
+ const char *place = is_result_type ? "return value" : "argument";
PyErr_Format(PyExc_NotImplementedError,
- "ctype '%s' not supported as argument or return value",
- ct->ct_name);
+ "ctype '%s' (size %zd) not supported as %s",
+ ct->ct_name, ct->ct_size, place);
return NULL;
}
}
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -2077,13 +2077,18 @@
ffi.cdef("typedef union { int a; float b; } Data;"
"typedef struct { int a:2; } MyStr;"
"typedef void (*foofunc_t)(Data);"
+ "typedef Data (*bazfunc_t)(void);"
"typedef MyStr (*barfunc_t)(void);")
fooptr = ffi.cast("foofunc_t", 123)
+ bazptr = ffi.cast("bazfunc_t", 123)
barptr = ffi.cast("barfunc_t", 123)
# assert did not crash so far
e = py.test.raises(NotImplementedError, fooptr, ffi.new("Data *"))
assert str(e.value) == (
- "ctype 'Data' not supported as argument or return value")
+ "ctype 'Data' (size 4) not supported as argument")
+ e = py.test.raises(NotImplementedError, bazptr)
+ assert str(e.value) == (
+ "ctype 'Data' (size 4) not supported as return value")
e = py.test.raises(NotImplementedError, barptr)
assert str(e.value) == (
"ctype 'MyStr' not supported as argument or return value "
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit