diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:06:33 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:06:33 +0000 |
commit | 686f1b98cdef9562e1e00b4ee4c3957acdbf7c19 (patch) | |
tree | b1639b8813fac071380e5bcd9b755d99f1012a78 /numpy | |
parent | 8028e7797548122b2f12d025c11f6a897b494dae (diff) | |
download | numpy-686f1b98cdef9562e1e00b4ee4c3957acdbf7c19.tar.gz |
3K: core: type fixes in numerictypes
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/numerictypes.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index f9ddf8ce1..f9938761d 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -494,13 +494,19 @@ def maximum_sctype(t): else: return sctypes[base][-1] +try: + buffer_type = _types.BufferType +except AttributeError: + # Py3K + buffer_type = memoryview + _python_types = {int : 'int_', float: 'float_', complex: 'complex_', bool: 'bool_', str: 'string_', unicode: 'unicode_', - _types.BufferType: 'void', + buffer_type: 'void', } def _python_type(t): """returns the type corresponding to a certain Python type""" @@ -722,9 +728,13 @@ def sctype2char(sctype): cast = _typedict() -ScalarType = [_types.IntType, _types.FloatType, - _types.ComplexType, _types.LongType, _types.BooleanType, - _types.StringType, _types.UnicodeType, _types.BufferType] +try: + ScalarType = [_types.IntType, _types.FloatType, _types.ComplexType, + _types.LongType, _types.BooleanType, + _types.StringType, _types.UnicodeType, _types.BufferType] +except AttributeError: + # Py3K + ScalarType = [int, float, complex, int, bool, bytes, str, memoryview] ScalarType.extend(_sctype2char_dict.keys()) ScalarType = tuple(ScalarType) for key in _sctype2char_dict.keys(): |