[pypy-svn] r75952 - in pypy/branch/interplevel-array/pypy: jit/codewriter module/array module/array/test

hakanardo at codespeak.net hakanardo at codespeak.net
Wed Jul 7 08:36:10 CEST 2010


Author: hakanardo
Date: Wed Jul  7 08:36:07 2010
New Revision: 75952

Modified:
   pypy/branch/interplevel-array/pypy/jit/codewriter/jtransform.py
   pypy/branch/interplevel-array/pypy/module/array/interp_array.py
   pypy/branch/interplevel-array/pypy/module/array/test/test_array.py
Log:
compilation now raises LLException: <LLException 'OperationError'>

Modified: pypy/branch/interplevel-array/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/jit/codewriter/jtransform.py	(original)
+++ pypy/branch/interplevel-array/pypy/jit/codewriter/jtransform.py	Wed Jul  7 08:36:07 2010
@@ -709,8 +709,9 @@
         size2, unsigned2 = size_and_sign(op.result.concretetype)
         if size1 == size2 and unsigned1 == unsigned2:
             return
-        raise NotImplementedError("cast not supported yet: %s" % (op, ))
-
+        raise NotImplementedError("cast not supported yet: %s (%s->%s)" %
+                                  (op, op.args[0].concretetype,
+                                   op.result.concretetype))
 
     # ----------
     # Renames, from the _old opname to the _new one.

Modified: pypy/branch/interplevel-array/pypy/module/array/interp_array.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/array/interp_array.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/array/interp_array.py	Wed Jul  7 08:36:07 2010
@@ -33,16 +33,16 @@
 types = {
     'c': TypeCode(lltype.Char,        'str_w'),
     'u': TypeCode(lltype.UniChar,     'unicode_w'),
-    'b': TypeCode(rffi.SIGNEDCHAR,    'int_w', True, True),
-    'B': TypeCode(rffi.UCHAR,         'int_w', True),
-    'h': TypeCode(rffi.SHORT,         'int_w', True, True),
-    'H': TypeCode(rffi.USHORT,        'int_w', True),
-    'i': TypeCode(rffi.INT,           'int_w', True, True),
-    'I': TypeCode(rffi.UINT,          'int_w', True),
-    'l': TypeCode(rffi.LONG,          'int_w', True, True),
+    #'b': TypeCode(rffi.SIGNEDCHAR,    'int_w', True, True),
+    #'B': TypeCode(rffi.UCHAR,         'int_w', True),
+    #'h': TypeCode(rffi.SHORT,         'int_w', True, True),
+    #'H': TypeCode(rffi.USHORT,        'int_w', True),
+    #'i': TypeCode(rffi.INT,           'int_w', True, True),
+    #'I': TypeCode(rffi.UINT,          'int_w', True),
+    #'l': TypeCode(rffi.LONG,          'int_w', True, True),
     #'L': TypeCode(rffi.ULONG,         'bigint_w', True), # FIXME: Won't compile
-    'f': TypeCode(lltype.SingleFloat, 'float_w'),
-    'd': TypeCode(lltype.Float,       'float_w'),
+    #'f': TypeCode(lltype.SingleFloat, 'float_w'),
+    #'d': TypeCode(lltype.Float,       'float_w'),
     }
 for k, v in types.items(): v.typecode=k
 unroll_typecodes = unrolling_iterable(types.keys())
@@ -59,7 +59,7 @@
             space = self.space
             unwrap = getattr(space, self.mytype.unwrap)
             item = unwrap(w_item)
-            if  self.mytype.unwrap == 'bigint_w':
+            if self.mytype.unwrap == 'bigint_w':
                 try:
                     if self.mytype.signed:
                         item = item.tolonglong()
@@ -68,6 +68,11 @@
                 except (ValueError, OverflowError):
                     msg = 'unsigned %d-byte integer out of range' % self.mytype.bytes
                     raise OperationError(space.w_OverflowError, space.wrap(msg))
+            elif self.mytype.unwrap == 'str_w' or self.mytype.unwrap == 'unicode_w':
+                if len(item) != 1:
+                    msg = 'array item must be char'
+                    raise OperationError(space.w_TypeError, space.wrap(msg))
+                item=item[0]
 
             if self.mytype.canoverflow:
                 msg = None

Modified: pypy/branch/interplevel-array/pypy/module/array/test/test_array.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/array/test/test_array.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/array/test/test_array.py	Wed Jul  7 08:36:07 2010
@@ -30,6 +30,7 @@
 
         a = self.array('c')
         raises(TypeError, a.append, 7)
+        raises(TypeError, a.append, 'hi')
         a.append('h')
         assert a[0] == 'h'
         assert type(a[0]) is str
@@ -37,6 +38,7 @@
 
         a = self.array('u')
         raises(TypeError, a.append, 7)
+        raises(TypeError, a.append, u'hi')
         a.append(unicode('h'))
         assert a[0] == unicode('h')
         assert type(a[0]) is unicode



More information about the Pypy-commit mailing list