[pypy-commit] pypy numpy-dtype-alt: fix for rffi.cast(<some rffi int>, float)
alex_gaynor
noreply at buildbot.pypy.org
Sun Aug 28 22:35:00 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
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))
More information about the pypy-commit
mailing list