diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:06:35 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:06:35 +0000 |
commit | 77f8ea3de6190178e78669d235c90c91bfee5e61 (patch) | |
tree | 017cbf3a3d56bdda54253a59eb58b762bbadb7f2 /numpy/compat | |
parent | 02aeb9bdd0411f0119cfbdb9456a37cdd2d4cc02 (diff) | |
download | numpy-77f8ea3de6190178e78669d235c90c91bfee5e61.tar.gz |
3K: core: adjust some tests vs. str/bytes and int inheritance issues
Diffstat (limited to 'numpy/compat')
-rw-r--r-- | numpy/compat/py3k.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index 931044787..b6113b661 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -3,7 +3,8 @@ Python 3 compatibility tools. """ -__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar'] +__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', + 'asunicode'] import sys @@ -14,6 +15,7 @@ if sys.version_info[0] >= 3: if isinstance(s, bytes): return s return s.encode('iso-8859-1') + asunicode = str def isfileobj(f): return isinstance(f, io.IOBase) strchar = 'U' @@ -23,6 +25,10 @@ else: strchar = 'S' def isfileobj(f): return isinstance(f, file) + def asunicode(s): + if isinstance(s, unicode): + return s + return s.decode('iso-8859-1') def getexception(): return sys.exc_info()[1] |