summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-12-06 11:57:36 +0000
committerPauli Virtanen <pav@iki.fi>2009-12-06 11:57:36 +0000
commitaa7be886274a6535169e5866383cc997231cf99d (patch)
treefbff6fda87094b2cafda6478b729ebcc9caa7466 /numpy/core
parent5bebeb3cf3d9bfe0d67076d0575601bbf0cb8fd3 (diff)
downloadnumpy-aa7be886274a6535169e5866383cc997231cf99d.tar.gz
3K: handle most PyInt_ issues in multiarray.
Do *not* inherit PyIntArrType from PyLong on Py3 -- the is not fixed-range and the internal representations are quite different. Not inheriting is, in fact, what was already done on Py2 on platforms where the sizes didn't match.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src6
-rw-r--r--numpy/core/src/multiarray/descriptor.c6
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c10
3 files changed, 20 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index bffe9f332..a5e3c96bc 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -1394,7 +1394,13 @@ static void
PyObject *new, *args;
/* call out to the Python builtin given by convstr */
args = Py_BuildValue("(N)", temp);
+#if defined(NPY_PY3K)
+#define PyInt_Type PyLong_Type
+#endif
new = Py@convstr@_Type.tp_new(&Py@convstr@_Type, args, NULL);
+#if defined(NPY_PY3K)
+#undef PyInt_Type
+#endif
Py_DECREF(args);
temp = new;
if (temp == NULL) {
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 2f1028124..8f29fab29 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -1122,12 +1122,18 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
}
}
check_num = PyArray_OBJECT;
+#if !defined(NPY_PY3K)
if (obj == (PyObject *)(&PyInt_Type)) {
check_num = PyArray_LONG;
}
else if (obj == (PyObject *)(&PyLong_Type)) {
check_num = PyArray_LONGLONG;
}
+#else
+ if (obj == (PyObject *)(&PyLong_Type)) {
+ check_num = PyArray_LONG;
+ }
+#endif
else if (obj == (PyObject *)(&PyFloat_Type)) {
check_num = PyArray_DOUBLE;
}
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 9e5edbf3c..67110dc17 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -2755,9 +2755,11 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
if (PyType_Ready(&PyBool_Type) < 0) {
return -1;
}
+#if !defined(NPY_PY3K)
if (PyType_Ready(&PyInt_Type) < 0) {
return -1;
}
+#endif
if (PyType_Ready(&PyFloat_Type) < 0) {
return -1;
}
@@ -2829,13 +2831,17 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
SINGLE_INHERIT(Bool, Generic);
SINGLE_INHERIT(Byte, SignedInteger);
SINGLE_INHERIT(Short, SignedInteger);
-#if SIZEOF_INT == SIZEOF_LONG
+#if SIZEOF_INT == SIZEOF_LONG && !defined(NPY_PY3K)
DUAL_INHERIT(Int, Int, SignedInteger);
#else
SINGLE_INHERIT(Int, SignedInteger);
#endif
+#if !defined(NPY_PY3K)
DUAL_INHERIT(Long, Int, SignedInteger);
-#if SIZEOF_LONGLONG == SIZEOF_LONG
+#else
+ SINGLE_INHERIT(Long, SignedInteger);
+#endif
+#if SIZEOF_LONGLONG == SIZEOF_LONG && !defined(NPY_PY3K)
DUAL_INHERIT(LongLong, Int, SignedInteger);
#else
SINGLE_INHERIT(LongLong, SignedInteger);