summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-10-27 16:03:16 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-10-27 16:03:16 +0000
commit4a8eb74e8e925929f3e5fd6933e50bccc91d8e23 (patch)
treeb7fcab5a434e5797f086a78ef6727ad65a12a660 /numpy/core/src
parent9bc2e05fe3c5b886b906bbac37ff2d566669fd11 (diff)
downloadnumpy-4a8eb74e8e925929f3e5fd6933e50bccc91d8e23.tar.gz
Fix PyArray_Scalar to handle user-defined types.
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/arrayobject.c2
-rw-r--r--numpy/core/src/scalartypes.inc.src9
2 files changed, 10 insertions, 1 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 4230eeef0..cafba4e2c 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -1550,7 +1550,7 @@ PyArray_TypeNumFromName(char *str)
/*
returns typenum to associate with this type >=PyArray_USERDEF.
needs the userdecrs table and PyArray_NUMUSER variables
- defined in arratypes.inc
+ defined in arraytypes.inc
*/
/*MULTIARRAY_API
Register Data type
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src
index 91bfcc8a5..95ba5e96f 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.inc.src
@@ -189,6 +189,15 @@ PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)
NULL, NULL, 0, NULL);
if (r==NULL) {Py_XDECREF(outcode); return NULL;}
+ if (PyDataType_ISUSERDEF(typecode)) {
+ /* Use setitem to set array from scalar */
+ if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) {
+ Py_XDECREF(outcode);
+ Py_DECREF(r);
+ return NULL;
+ }
+ }
+
memptr = scalar_value(scalar, typecode);
#ifndef Py_UNICODE_WIDE
if (typecode->type_num == PyArray_UNICODE) {