[pypy-commit] cffi default: Tests, missing case.

arigo noreply at buildbot.pypy.org
Thu Jun 21 13:16:12 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r478:a877c860125f
Date: 2012-06-20 18:31 +0200
http://bitbucket.org/cffi/cffi/changeset/a877c860125f/

Log:	Tests, missing case.

diff --git a/c/_ffi_backend.c b/c/_ffi_backend.c
--- a/c/_ffi_backend.c
+++ b/c/_ffi_backend.c
@@ -1969,6 +1969,9 @@
             }
             value = (unsigned char)PyString_AS_STRING(io)[0];
         }
+        else if (io == Py_None) {
+            value = 0.0;
+        }
         else {
             value = PyFloat_AsDouble(io);
         }
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -114,6 +114,9 @@
 
         assert cast(p, -1.1) != cast(p, -1.1)
         assert repr(float(cast(p, -0.0))) == '-0.0'
+        assert float(cast(p, '\x09')) == 9.0
+        assert float(cast(p, True)) == 1.0
+        assert float(cast(p, None)) == 0.0
 
 def test_character_type():
     p = new_primitive_type("char")


More information about the pypy-commit mailing list