From: abn Date: Fri, 14 Apr 2023 12:00:17 +0000 (+0200) Subject: Minor: exception propagation when scipy not available was buggy X-Git-Tag: V9_11_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=77960750a1bd6711ace9136b8a61bd65a59cf8cb;p=tools%2Fmedcoupling.git Minor: exception propagation when scipy not available was buggy --- diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index d0e06d995..228c3aa9b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -3147,8 +3147,11 @@ bool isCSRMatrix(PyObject *m) PyObject* pdict(PyDict_New()); PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); PyObject *tmp(PyRun_String("from scipy.sparse import csr_matrix", Py_single_input, pdict, pdict)); - if(!tmp) - throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse ! Is Scipy module available in present ?"); + if (!tmp) + { + PyErr_Clear(); // Otherwise exception propagation will fail. + throw INTERP_KERNEL::Exception("Problem during loading csr_matrix in scipy.sparse! Is Scipy module available and present?"); + } PyObject *csrMatrixCls=PyDict_GetItemString(pdict,"csr_matrix"); if(!csrMatrixCls) throw INTERP_KERNEL::Exception("csr_matrix not found in scipy.sparse ! Is Scipy module available in present ?");