Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r513:ad29c07c0119 Date: 2012-06-25 21:27 +0200 http://bitbucket.org/cffi/cffi/changeset/ad29c07c0119/
Log: Test and fix. diff --git a/c/_ffi_backend.c b/c/_ffi_backend.c --- a/c/_ffi_backend.c +++ b/c/_ffi_backend.c @@ -764,6 +764,8 @@ if (!CData_Check(init)) goto cannot_convert; ctinit = ((CDataObject *)init)->c_type; + if (!(ctinit->ct_flags & (CT_POINTER|CT_FUNCTIONPTR|CT_ARRAY))) + goto cannot_convert; if (ctinit->ct_itemdescr != ct->ct_itemdescr && !(ct->ct_itemdescr->ct_flags & CT_CAST_ANYTHING)) goto cannot_convert; diff --git a/c/test_c.py b/c/test_c.py --- a/c/test_c.py +++ b/c/test_c.py @@ -1023,3 +1023,10 @@ assert str(a) == "hello" p = a + 2 assert str(p) == "llo" + +def test_bug_convert_to_ptr(): + BChar = new_primitive_type("char") + BCharP = new_pointer_type(BChar) + BDouble = new_primitive_type("double") + x = cast(BDouble, 42) + py.test.raises(TypeError, newp, new_pointer_type(BCharP), x) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit