Author: Alex Gaynor <[email protected]>
Branch: numpy-dtype-alt
Changeset: r46868:cbeba1490325
Date: 2011-08-28 20:33 +0000
http://bitbucket.org/pypy/pypy/changeset/cbeba1490325/
Log: fix for rffi.cast(<some rffi int>, float)
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
@@ -20,7 +20,7 @@
from pypy.rpython.extfunc import ExtRegistryEntry
from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic
from pypy.tool.uid import fixid
-from pypy.rlib.rarithmetic import r_uint, r_singlefloat, r_longfloat, intmask
+from pypy.rlib.rarithmetic import r_uint, r_singlefloat, r_longfloat,
base_int, intmask
from pypy.annotation import model as annmodel
from pypy.rpython.llinterp import LLInterpreter, LLException
from pypy.rpython.lltypesystem.rclass import OBJECT, OBJECT_VTABLE
@@ -1142,6 +1142,8 @@
cvalue = 0
elif isinstance(cvalue, (str, unicode)):
cvalue = ord(cvalue) # character -> integer
+ elif hasattr(RESTYPE, "_type") and issubclass(RESTYPE._type, base_int):
+ cvalue = int(cvalue)
if not isinstance(cvalue, (int, long, float)):
raise NotImplementedError("casting %r to %r" % (TYPE1, RESTYPE))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit