From 3a5c5475b5c2043dbe6791d3a5100a45d491546e Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 17 Apr 2013 00:04:46 -0600 Subject: 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. --- numpy/lib/tests/test_regression.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/lib/tests') diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index 3b70d1ff0..1e9bacdf5 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -1,9 +1,11 @@ from __future__ import division, absolute_import, print_function import sys + +import numpy as np from numpy.testing import * from numpy.testing.utils import _assert_valid_refcount -import numpy as np +from numpy.compat import unicode rlevel = 1 -- cgit v1.2.1