Commits

Armin Rigo committed e582b09

Test and fix

Comments (0)

Files changed (2)

c/_cffi_backend.c

     }
     if (ct->ct_flags & CT_PRIMITIVE_FLOAT) {
         double value = PyFloat_AsDouble(init);
+        if (value == -1.0 && PyErr_Occurred())
+            return -1;
         write_raw_float_data(data, value, ct->ct_size);
         return 0;
     }
     BArray = new_array_type(BIntP, 3)
     x = cast(BArray, 0)
     assert repr(x) == "<cdata 'int[3]' NULL>"
+
+def test_bug_float_convertion():
+    BDouble = new_primitive_type("double")
+    BDoubleP = new_pointer_type(BDouble)
+    py.test.raises(TypeError, newp, BDoubleP, "foobar")