summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/scalartypes.inc.src16
-rw-r--r--numpy/core/tests/test_regression.py2
2 files changed, 8 insertions, 10 deletions
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src
index 764b7ba46..3855a6eb3 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.inc.src
@@ -1923,10 +1923,8 @@ static PyObject *
#elif @default@ == 1
robj = PyArray_Scalar(NULL, typecode, NULL);
#elif @default@ == 2
- obj = Py_None;
- robj = type->tp_alloc(type, 0);
Py_INCREF(Py_None);
- ((PyObjectScalarObject *)robj)->obval = obj;
+ robj = Py_None;
#endif
Py_DECREF(typecode);
goto finish;
@@ -1942,14 +1940,15 @@ static PyObject *
/* 0-d array */
robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr);
Py_DECREF(arr);
+
+finish:
+
#if @default@ == 2 /* In OBJECT case, robj is no longer a
PyArrayScalar at this point but the
remaining code assumes it is
*/
return robj;
-#endif
-
-finish:
+#else
/* Normal return */
if ((robj == NULL) || (robj->ob_type == type)) {
return robj;
@@ -1983,12 +1982,11 @@ finish:
itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);
}
memcpy(dest, src, itemsize);
-#elif @default@ == 2 /* Object arrays */
- memcpy(dest, src, sizeof(void *));
- Py_INCREF(*((PyObject **)dest));
+ /* @default@ == 2 won't get here */
#endif
Py_DECREF(robj);
return obj;
+#endif
}
/**end repeat**/
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index ff9c7e2e6..c92ad4779 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1196,7 +1196,7 @@ class TestRegression(TestCase):
assert type(b2) is float
assert type(c) is np.ndarray
assert c.dtype == object
- assert d.type == object
+ assert d.dtype == object
if __name__ == "__main__":
run_module_suite()