Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r75196:ae5a2b000fdb
Date: 2014-12-31 16:59 +0100
http://bitbucket.org/pypy/pypy/changeset/ae5a2b000fdb/

Log:    Array module: Implement the LongLong typecodes.

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -52,7 +52,7 @@
                         a.descr_frombytes(space, buf)
             break
     else:
-        msg = 'bad typecode (must be b, B, u, h, H, i, I, l, L, f or d)'
+        msg = 'bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)'
         raise OperationError(space.w_ValueError, space.wrap(msg))
 
     return a
@@ -620,6 +620,8 @@
                                                     # rbigint.touint() which
                                                     # corresponds to the
                                                     # C-type unsigned long
+    'q': TypeCode(rffi.LONGLONG,      'bigint_w', True, True),
+    'Q': TypeCode(rffi.ULONGLONG,     'bigint_w', True),
     'f': TypeCode(lltype.SingleFloat, 'float_w', method='__float__'),
     'd': TypeCode(lltype.Float,       'float_w', method='__float__'),
     }
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -8,7 +8,7 @@
 
         raises(TypeError, self.array, 'hi')
         raises(TypeError, self.array, 1)
-        raises(ValueError, self.array, 'q')
+        raises(ValueError, self.array, 'x')
 
         a = self.array('u')
         raises(TypeError, a.append, 7)
@@ -22,7 +22,7 @@
         b = self.array('h', (1, 2, 3))
         assert a == b
 
-        for tc in 'bhilBHILfd':
+        for tc in 'bhilBHILQqfd':
             assert self.array(tc).typecode == tc
             raises(TypeError, self.array, tc, None)
 
@@ -111,6 +111,8 @@
             assert(self.array(t).itemsize >= 4)
         for t in 'd':
             assert(self.array(t).itemsize >= 8)
+        for t in 'Qq':
+            assert(self.array(t).itemsize >= 8)
 
         inttypes = 'bhil'
         for t in inttypes:
@@ -143,7 +145,7 @@
         a.fromstring('')
         assert not len(a)
 
-        for t in 'bBhHiIlLfd':
+        for t in 'bBhHiIlLfdQq':
             a = self.array(t)
             a.fromstring('\x00' * a.itemsize * 2)
             assert len(a) == 2 and a[0] == 0 and a[1] == 0
@@ -717,13 +719,13 @@
         assert repr(a) == "array('i', [4, 3, 2, 1, 0])"
 
     def test_type(self):
-        for t in 'bBhHiIlLfdu':
+        for t in 'bBhHiIlLfduQq':
             assert type(self.array(t)) is self.array
             assert isinstance(self.array(t), self.array)
 
     def test_iterable(self):
         import collections
-        for t in 'bBhHiIlLfdu':
+        for t in 'bBhHiIlLfduQq':
             assert isinstance(self.array(t), collections.Iterable)
 
     def test_subclass(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to