[pypy-commit] pypy default: encode unicode dtype spec to ascii

mattip noreply at buildbot.pypy.org
Thu Apr 23 00:26:45 CEST 2015


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r76895:2301f0bf4a68
Date: 2015-04-23 01:24 +0300
http://bitbucket.org/pypy/pypy/changeset/2301f0bf4a68/

Log:	encode unicode dtype spec to ascii

diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -545,6 +545,8 @@
                        space.gettypefor(boxes.W_VoidBox),
                        shape=shape, subdtype=subdtype, elsize=size)
 
+    if space.isinstance_w(w_dtype, space.w_unicode):
+        w_dtype = space.wrap(space.str_w(w_dtype)) # may raise if invalid
     if space.is_none(w_dtype):
         return cache.w_float64dtype
     elif space.isinstance_w(w_dtype, w_subtype):
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -58,6 +58,7 @@
         assert exc.value[0] == "there are no fields defined"
 
         assert dtype('int8').num == 1
+        assert dtype(u'int8').num == 1
         assert dtype('int8').name == 'int8'
         assert dtype('void').name == 'void'
         assert dtype(int).fields is None


More information about the pypy-commit mailing list