diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-03-21 01:41:27 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-03-21 01:41:27 +0300 |
commit | 0c7e5323e891e5b32b4bfae58115137e805adfeb (patch) | |
tree | a92d0320b3bef22e80683cf38d4b241a9e35806e /source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp | |
parent | 6ba34d18b55bedbddb750e5231a2aec9a1fbbac0 (diff) |
Improvements in error handling at Python-C++ boundaries.
Diffstat (limited to 'source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp index 48725589e68..1dd24b1fbb7 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp @@ -257,13 +257,17 @@ PyObject * UnaryFunction1DDouble___call__( BPy_UnaryFunction1DDouble *self, PyOb { PyObject *obj; - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) { - cout << "ERROR: UnaryFunction1DDouble___call__ " << endl; + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) return NULL; - } - double d = self->uf1D_double->operator()(*( ((BPy_Interface1D *) obj)->if1D )); - return PyFloat_FromDouble( d ); + if (self->uf1D_double->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_double->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf1D_double->result ); } @@ -271,10 +275,8 @@ PyObject * UnaryFunction1DDouble_setIntegrationType(BPy_UnaryFunction1DDouble* s { PyObject *obj; - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) { - cout << "ERROR: UnaryFunction1DDouble_setIntegrationType " << endl; - Py_RETURN_NONE; - } + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; self->uf1D_double->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); Py_RETURN_NONE; |