summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury V. Zaytsev <yury@shurup.com>2013-07-16 11:29:22 +0200
committerYury V. Zaytsev <yury@shurup.com>2013-08-10 21:28:01 +0200
commit1234688ae809870007b73b4a8816711a60f8e62c (patch)
tree1c399aaa2241dfc579433254d67ac313647e493d
parentc6da120806f70d417619e1a34512f38dbd0dcc8d (diff)
downloadnumpy-1234688ae809870007b73b4a8816711a60f8e62c.tar.gz
BUG: Fix PyType_FastSubclass() check for numpy.int_
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 7ec7ab639..f8e434e67 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -3783,6 +3783,19 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
} \
Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;
+/*
+ * In Py3K, int is no longer a fixed-width integer type, so don't
+ * inherit numpy.int_ from it.
+ */
+#if defined(NPY_PY3K)
+#define INHERIT_INT(child, parent2) \
+ SINGLE_INHERIT(child, parent2);
+#else
+#define INHERIT_INT(child, parent2) \
+ Py##child##ArrType_Type.tp_flags |= Py_TPFLAGS_INT_SUBCLASS; \
+ DUAL_INHERIT(child, Int, parent2);
+#endif
+
#if defined(NPY_PY3K)
#define DUAL_INHERIT_COMPARE(child, parent1, parent2)
#else
@@ -3811,18 +3824,17 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
SINGLE_INHERIT(Bool, Generic);
SINGLE_INHERIT(Byte, SignedInteger);
SINGLE_INHERIT(Short, SignedInteger);
-#if NPY_SIZEOF_INT == NPY_SIZEOF_LONG && !defined(NPY_PY3K)
- DUAL_INHERIT(Int, Int, SignedInteger);
+
+#if NPY_SIZEOF_INT == NPY_SIZEOF_LONG
+ INHERIT_INT(Int, SignedInteger);
#else
SINGLE_INHERIT(Int, SignedInteger);
#endif
-#if !defined(NPY_PY3K)
- DUAL_INHERIT(Long, Int, SignedInteger);
-#else
- SINGLE_INHERIT(Long, SignedInteger);
-#endif
-#if NPY_SIZEOF_LONGLONG == NPY_SIZEOF_LONG && !defined(NPY_PY3K)
- DUAL_INHERIT(LongLong, Int, SignedInteger);
+
+ INHERIT_INT(Long, SignedInteger);
+
+#if NPY_SIZEOF_LONGLONG == NPY_SIZEOF_LONG
+ INHERIT_INT(LongLong, SignedInteger);
#else
SINGLE_INHERIT(LongLong, SignedInteger);
#endif
@@ -3864,6 +3876,9 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
#undef SINGLE_INHERIT
#undef DUAL_INHERIT
+#undef INHERIT_INT
+#undef DUAL_INHERIT2
+#undef DUAL_INHERIT_COMPARE
/*
* Clean up string and unicode array types so they act more like