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

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Feb 20 21:46:08 EST 2010


Author: ptvirtan
Date: 2010-02-20 20:46:08 -0600 (Sat, 20 Feb 2010)
New Revision: 8199

Modified:
   trunk/numpy/core/numerictypes.py
Log:
3K: core/numerictypes: fix handling of Python types, and recognize bytes as a Python type

Modified: trunk/numpy/core/numerictypes.py
===================================================================
--- trunk/numpy/core/numerictypes.py	2010-02-21 02:45:48 UTC (rev 8198)
+++ trunk/numpy/core/numerictypes.py	2010-02-21 02:46:08 UTC (rev 8199)
@@ -99,10 +99,10 @@
 # we don't export these for import *, but we do want them accessible
 # as numerictypes.bool, etc.
 from __builtin__ import bool, int, long, float, complex, object, unicode, str
+from numpy.compat import bytes
 
 if sys.version_info[0] >= 3:
     # Py3K
-    from builtins import bytes
     class long(int):
         # Placeholder class -- this will not escape outside numerictypes.py
         pass
@@ -542,16 +542,24 @@
                  float: 'float_',
                  complex: 'complex_',
                  bool: 'bool_',
-                 str: 'string_',
+                 bytes: 'bytes_',
                  unicode: 'unicode_',
                  buffer_type: 'void',
                 }
-def _python_type(t):
-    """returns the type corresponding to a certain Python type"""
-    if not isinstance(t, _types.TypeType):
-        t = type(t)
-    return allTypes[_python_types.get(t, 'object_')]
 
+if sys.version_info[0] >= 3:
+    def _python_type(t):
+        """returns the type corresponding to a certain Python type"""
+        if not isinstance(t, type):
+            t = type(t)
+        return allTypes[_python_types.get(t, 'object_')]
+else:
+    def _python_type(t):
+        """returns the type corresponding to a certain Python type"""
+        if not isinstance(t, _types.TypeType):
+            t = type(t)
+        return allTypes[_python_types.get(t, 'object_')]
+
 def issctype(rep):
     """
     Determines whether the given object represents a scalar data-type.




More information about the Numpy-svn mailing list