Skip to content

Commit

Permalink
Fix infinite recursion when initializing sub-class of array scalars.
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Feb 26, 2014
1 parent 3ba223e commit 149359f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions numpy/core/src/multiarray/scalartypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -2459,10 +2459,13 @@ object_arrtype_dealloc(PyObject *v)
/* We are inheriting from a Python type as well so \
give it first dibs on conversion */ \
sup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, num); \
robj = sup->tp_new(type, args, kwds); \
if (robj != NULL) goto finish; \
if (PyTuple_GET_SIZE(args)!=1) return NULL; \
PyErr_Clear(); \
/* Prevent recursion */ \
if (thisfunc != sup->tp_new) { \
robj = sup->tp_new(type, args, kwds); \
if (robj != NULL) goto finish; \
if (PyTuple_GET_SIZE(args)!=1) return NULL; \
PyErr_Clear(); \
} \
/* now do default conversion */ \
}

Expand Down Expand Up @@ -2498,6 +2501,9 @@ static PyObject *
PyObject *robj;
PyArrayObject *arr;
PyArray_Descr *typecode = NULL;
#if (@work@ != 0) || (@default@ == 1)
void *thisfunc = (void *)@name@_arrtype_new;
#endif
#if !(@default@ == 2)
int itemsize;
void *dest, *src;
Expand Down

0 comments on commit 149359f

Please sign in to comment.