diff options
Diffstat (limited to 'numpy/compat/py3k.py')
-rw-r--r-- | numpy/compat/py3k.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index ce79edde8..e7ab9bf0f 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -6,7 +6,7 @@ from __future__ import division, absolute_import, print_function __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', 'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested', - 'asstr', 'open_latin1', 'long', 'basestring'] + 'asstr', 'open_latin1', 'long', 'basestring', 'sixu'] import sys @@ -16,8 +16,8 @@ if sys.version_info[0] >= 3: long = int integer_types = (int,) basestring = str - bytes = bytes unicode = str + bytes = bytes def asunicode(s): if isinstance(s, bytes): @@ -40,14 +40,17 @@ if sys.version_info[0] >= 3: def open_latin1(filename, mode='r'): return open(filename, mode=mode, encoding='iso-8859-1') + def sixu(s): + return s + strchar = 'U' else: bytes = str - unicode = unicode long = long basestring = basestring + unicode = unicode integer_types = (int, long) asbytes = str asstr = str @@ -65,6 +68,9 @@ else: def open_latin1(filename, mode='r'): return open(filename, mode=mode) + def sixu(s): + return unicode(s, 'unicode_escape') + def getexception(): return sys.exc_info()[1] |