[Matrix-SIG] Patch for multiarraymodule.c

Charles G Waldman cgw@fnal.gov
Wed, 26 May 1999 11:53:04 -0500 (CDT)


The symptom:

Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from Matrix import *
>>> m = Matrix([1,1],[1,0])
Segmentation fault (core dumped)

The cure:

--- multiarraymodule.c	1999/05/26 16:43:37	1.1
+++ multiarraymodule.c	1999/05/26 16:50:59
@@ -864,6 +864,11 @@
 	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];