Author: Ronan Lamy <[email protected]>
Branch: unicode-dtype
Changeset: r78004:3591f1ef0fb0
Date: 2015-06-09 19:20 +0100
http://bitbucket.org/pypy/pypy/changeset/3591f1ef0fb0/

Log:    fix unicode array creation

diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -325,10 +325,11 @@
 
     def test_unicode(self):
         import numpy as np
-        a = np.array([u'A&#255;', u'abc'], dtype=np.dtype('U'))
-        assert a.shape == (2,)
+        a = np.array([3, u'A&#255;', ''], dtype='U3')
+        assert a.shape == (3,)
         assert a.dtype == np.dtype('U3')
-        assert a[0] == u'A&#255;'
+        assert a[0] == u'3'
+        assert a[1] == u'A&#255;'
 
     def test_dtype_attribute(self):
         import numpy as np
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -2189,7 +2189,7 @@
     def coerce(self, space, dtype, w_item):
         if isinstance(w_item, boxes.W_UnicodeBox):
             return w_item
-        value = space.unicode_w(w_item)
+        value = space.unicode_w(space.unicode_from_object(w_item))
         return boxes.W_UnicodeBox(value)
 
     def store(self, arr, i, offset, box, native):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to