diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-17 00:04:46 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-21 20:56:15 -0600 |
commit | 3a5c5475b5c2043dbe6791d3a5100a45d491546e (patch) | |
tree | 9f0445f0258c4252a120005e218ae18ec526fba7 /numpy/ma | |
parent | 56e806abb78ac03a5f45090a3b9bf7a6c9964026 (diff) | |
download | numpy-3a5c5475b5c2043dbe6791d3a5100a45d491546e.tar.gz |
2to3: Apply unicode fixer.
The unicode fixer strips the u from u'hi' and converts the unicode type
to str. The first won't work for Python 2 and instead we replace the u
prefix with the sixu function borrowed from the six compatibility
package. That function calls the unicode constructor with the
'unicode_escape' encoder so that the many tests using escaped unicode
characters like u'\u0900' will be handled correctly. That makes the
sixu function a bit different from the asunicode function currently in
numpy.compat and also provides a target that can be converted back to
the u prefix when support for Python 3.2 is dropped. Python 3.3
reintroduced the u prefix for compatibility.
The unicode fixer also replaces 'unicode' with 'str' as 'unicode' is no
longer a builtin in Python 3. For code compatibility, 'unicode' is
defined either as 'str' or 'unicode' in numpy.compat so that checks like
if isinstance(x, unicode):
...
will work properly for all python versions.
Closes #3089.
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/tests/test_regression.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py index 917c53969..f713a8a1a 100644 --- a/numpy/ma/tests/test_regression.py +++ b/numpy/ma/tests/test_regression.py @@ -1,8 +1,9 @@ from __future__ import division, absolute_import, print_function -from numpy.testing import * import numpy as np import numpy.ma as ma +from numpy.testing import * +from numpy.compat import sixu rlevel = 1 @@ -38,7 +39,7 @@ class TestRegression(TestCase): def test_masked_array_repr_unicode(self): """Ticket #1256""" - repr(np.ma.array(u"Unicode")) + repr(np.ma.array(sixu("Unicode"))) def test_atleast_2d(self): """Ticket #1559""" |