[Matrix-SIG] Previous solution dumps core due to typo and long-standing bug.
Travis Oliphant
Oliphant.Travis@mayo.edu
Fri, 3 Sep 1999 18:48:00 -0500 (CDT)
The previous solution I just posted dumped core when used on arrays
with rank > 0 (I had just tried it with rank-0 arrays).
The mistake is that copy should be copy=copy in the call to self.__class__
in _arrayret.
The reason it dumps core is due to a long-standing bug that has still not
been fixed the solution to which was posted by Charles Waldman May 26.
The C-code uses the typecode argument as a string without first making
sure it is a string:
The following (indicated with +) needs to be added to both array_array in
multiarraymodule.c and now array_init in arraymodule.c:
if (tpo == Py_None) {
type = PyArray_NOTYPE;
} else {
+ if (!PyString_Check(tpo)){
+ PyErr_SetString(PyExc_TypeError,
+ "typecode must be a character");
+ return NULL;
+ }
tp = PyString_AsString(tpo);
if (tp[0] == 0) type = PyArray_NOTYPE;
else type = tp[0];
Travis