summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-27 03:32:19 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-27 03:32:19 +0000
commit3263664f0dab43f4fe75017027d4fd74a30f89be (patch)
tree0230841f5de1f98c35a32cd06e83aa68c4a0f99f
parente3af9216b8db1653c0cff98f3b861458b7c388db (diff)
downloadnumpy-3263664f0dab43f4fe75017027d4fd74a30f89be.tar.gz
allow _fillobject to handle non-object cases.
-rw-r--r--numpy/core/src/arrayobject.c16
-rw-r--r--numpy/core/src/scalartypes.inc.src2
2 files changed, 16 insertions, 2 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index fd0fe4122..59a83a04f 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -5035,7 +5035,21 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
static void
_fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype)
{
- if (!dtype->hasobject) return;
+ if (!dtype->hasobject) {
+ if ((obj == Py_None) ||
+ (PyInt_Check(obj) && PyInt_AsLong(obj)==0))
+ return;
+ else {
+ PyObject *arr;
+ Py_INCREF(dtype);
+ arr = PyArray_NewFromDescr(&PyArray_Type, dtype,
+ 0, NULL, NULL, NULL,
+ 0, NULL);
+ if (arr!=NULL)
+ dtype->f->setitem(obj, optr, arr);
+ Py_XDECREF(arr);
+ }
+ }
if (PyDescr_ISOBJECT(dtype)) {
PyObject **temp;
Py_XINCREF(obj);
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src
index 5aa0cb89e..011a6c69b 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.inc.src
@@ -1139,7 +1139,7 @@ voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
PyObject *value, *src;
int mysize;
char *dptr;
- static char *kwlist[] = {"value", "dtype", "offset", 0};/* XXX ? */
+ static char *kwlist[] = {"value", "dtype", "offset", 0};
if ((self->flags & WRITEABLE) != WRITEABLE) {
PyErr_SetString(PyExc_RuntimeError,