Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r638:e582b09b9d40
Date: 2012-07-13 20:39 +0200
http://bitbucket.org/cffi/cffi/changeset/e582b09b9d40/

Log:    Test and fix

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -877,6 +877,8 @@
     }
     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;
     }
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1558,3 +1558,8 @@
     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")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to