[pypy-commit] pypy default: Fix for rffi.cast(lltype.Float, r_singlefloat(2))
alex_gaynor
noreply at buildbot.pypy.org
Fri Nov 11 17:40:30 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r49329:5ca4800e4a5d
Date: 2011-11-11 11:40 -0500
http://bitbucket.org/pypy/pypy/changeset/5ca4800e4a5d/
Log: Fix for rffi.cast(lltype.Float, r_singlefloat(2))
diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py
--- a/pypy/rpython/lltypesystem/ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/ll2ctypes.py
@@ -1163,6 +1163,8 @@
value = value.adr
if isinstance(value, llmemory.fakeaddress):
value = value.ptr or 0
+ if isinstance(value, r_singlefloat):
+ value = float(value)
TYPE1 = lltype.typeOf(value)
cvalue = lltype2ctypes(value)
cresulttype = get_ctypes_type(RESTYPE)
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -710,6 +710,9 @@
res = cast(lltype.SingleFloat, res)
assert res == r_singlefloat(12.3)
+ res = cast(lltype.Float, r_singlefloat(12.))
+ assert res == 12.
+
def test_rffi_sizeof(self):
try:
import ctypes
More information about the pypy-commit
mailing list