From 1b83d85bc4cfaccb12295d993c5a12e5c4029030 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Mon, 17 Feb 2014 14:47:44 -0700 Subject: BUG: #2408, Fix f2py Python 3 error message string bug. The original was generating an exception message and, after aliasing, calling PyBytes_AsString on a unicode string -> error. It was also leaking references, although that probably didn't matter in context. The fix here is on the cheap side, just use a C string for the message without including the extra information about the erroneous type that led to the exception. No test, I don't know how to evoke this error. Closes #2408. --- numpy/f2py/src/fortranobject.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'numpy/f2py/src/fortranobject.c') diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index 0cc32348e..9c96c1f46 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -741,14 +741,12 @@ PyArrayObject* array_from_pyobj(const int type_num, return arr; } - if ((intent & F2PY_INTENT_INOUT) - || (intent & F2PY_INTENT_INPLACE) - || (intent & F2PY_INTENT_CACHE)) { - sprintf(mess,"failed to initialize intent(inout|inplace|cache) array" - " -- input must be array but got %s", - PyString_AsString(PyObject_Str(PyObject_Type(obj))) - ); - PyErr_SetString(PyExc_TypeError,mess); + if ((intent & F2PY_INTENT_INOUT) || + (intent & F2PY_INTENT_INPLACE) || + (intent & F2PY_INTENT_CACHE)) { + PyErr_SetString(PyExc_TypeError, + "failed to initialize intent(inout|inplace|cache) " + "array, input not an array"); return NULL; } -- cgit v1.2.1