From 0c7e5323e891e5b32b4bfae58115137e805adfeb Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Fri, 20 Mar 2009 22:41:27 +0000 Subject: Improvements in error handling at Python-C++ boundaries. --- .../python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp') diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index 98cecfa1e77..754a432a336 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DUnsigned___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - unsigned int i = self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); - return PyInt_FromLong( i ); + if (self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_unsigned->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyInt_FromLong( self->uf0D_unsigned->result ); } -- cgit v1.2.3