Commits

Brian Kearns committed 1b0b29a

fix creation of dtype('c#')

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_dtype.py

             size = int(name[1:])
         except ValueError:
             raise OperationError(space.w_TypeError, space.wrap("data type not understood"))
-    if char == 'S' or char == 'c':
+    if char == 'c':
+        char = 'S'
+        size = 1
+    if char == 'S':
         itemtype = types.StringType(size)
         basename = 'string'
         num = 18

pypy/module/micronumpy/test/test_dtypes.py

         assert d.type is str_
         assert d.name == "string64"
         assert d.num == 18
+        for i in [1, 2, 3]:
+            d = dtype('c%d' % i)
+            assert d.itemsize == 1
+            assert d.kind == 'S'
+            assert d.type is str_
+            assert d.name == 'string8'
+            assert d.num == 18
+            assert d.str == '|S1'
 
     def test_unicode_dtype(self):
         from numpypy import dtype, unicode_