[pypy-svn] r79368 - pypy/branch/reflex-support/pypy/module/cppyy

wlav at codespeak.net wlav at codespeak.net
Mon Nov 22 23:16:31 CET 2010


Author: wlav
Date: Mon Nov 22 23:16:30 2010
New Revision: 79368

Modified:
   pypy/branch/reflex-support/pypy/module/cppyy/converter.py
Log:
for rtyper: use rffi cast rather than chr

Modified: pypy/branch/reflex-support/pypy/module/cppyy/converter.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/converter.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/converter.py	Mon Nov 22 23:16:30 2010
@@ -91,10 +91,12 @@
     def _from_space(self, space, w_value):
         # allow int to pass to char and make sure that str is of length 1
         if space.isinstance_w(w_value, space.w_int):
-            try:
-                value = chr(space.c_int_w(w_value))     
-            except ValueError, e:
-                raise OperationError(space.w_TypeError, space.wrap(str(e)))
+            ival = space.c_int_w(w_value)
+            if ival < 0 or 256 <= ival:
+                raise OperationError(space.w_TypeError,
+                                     space.wrap("char arg not in range(256)"))
+
+            value = rffi.cast(rffi.CHAR, space.c_int_w(w_value))
         else:
             value = space.str_w(w_value)
 



More information about the Pypy-commit mailing list