[pypy-commit] cffi default: Fix for test_vgen.test_struct_returned_by_func (and uniformize the error message)

arigo noreply at buildbot.pypy.org
Fri Apr 24 11:53:42 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1790:3fcfce174377
Date: 2015-04-24 11:54 +0200
http://bitbucket.org/cffi/cffi/changeset/3fcfce174377/

Log:	Fix for test_vgen.test_struct_returned_by_func (and uniformize the
	error message)

diff --git a/cffi/vengine_gen.py b/cffi/vengine_gen.py
--- a/cffi/vengine_gen.py
+++ b/cffi/vengine_gen.py
@@ -190,6 +190,10 @@
                     indirect_args.append(typ)
                 indirect_result = tp.result
                 if isinstance(indirect_result, model.StructOrUnion):
+                    if indirect_result.fldtypes is None:
+                        raise TypeError("'%s' is used as result type, "
+                                        "but is opaque" % (
+                                            indirect_result._get_c_name(),))
                     indirect_result = model.PointerType(indirect_result)
                     indirect_args.insert(0, indirect_result)
                     indirections.insert(0, ("result", indirect_result))
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1680,9 +1680,8 @@
     e = py.test.raises(TypeError, ffi.verify,
                        "typedef struct { int x; } foo_t; "
                        "foo_t myfunc(void) { foo_t x = { 42 }; return x; }")
-    assert str(e.value) in [
-        "function myfunc: 'foo_t' is used as result type, but is opaque",
-        "function myfunc: result type 'foo_t' is opaque"]
+    assert str(e.value) == (
+        "function myfunc: 'foo_t' is used as result type, but is opaque")
 
 def test_include():
     ffi1 = FFI()


More information about the pypy-commit mailing list