[Numpy-svn] r8146 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:07:57 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:07:57 -0600 (Sat, 20 Feb 2010)
New Revision: 8146

Modified:
   trunk/numpy/core/defchararray.py
Log:
3K: BUG: core: fix some bytes/str issues in defchararray.py

Modified: trunk/numpy/core/defchararray.py
===================================================================
--- trunk/numpy/core/defchararray.py	2010-02-20 18:07:43 UTC (rev 8145)
+++ trunk/numpy/core/defchararray.py	2010-02-20 18:07:57 UTC (rev 8146)
@@ -38,8 +38,10 @@
 _globalvar = 0
 if sys.version_info[0] >= 3:
     _unicode = str
+    _bytes = bytes
 else:
     _unicode = unicode
+    _bytes = str
 _len = len
 
 def _use_unicode(*args):
@@ -2583,7 +2585,7 @@
         be in any order (either C-, Fortran-contiguous, or even
         discontiguous).
     """
-    if isinstance(obj, (str, _unicode)):
+    if isinstance(obj, (_bytes, _unicode)):
         if unicode is None:
             if isinstance(obj, _unicode):
                 unicode = True
@@ -2621,7 +2623,7 @@
         else:
             # Let the default Unicode -> string encoding (if any) take
             # precedence.
-            obj = str(obj)
+            obj = _bytes(obj)
 
         return chararray(shape, itemsize=itemsize, unicode=unicode,
                          buffer=obj, order=order)



More information about the Numpy-svn mailing list