diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-04-01 02:45:11 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-04-01 02:45:11 +0400 |
commit | 67e4d7dc63a6654b848d9966991ca2b507b78aa7 (patch) | |
tree | 57e8ed68a5103afb770ee6bbeabf200ac210a5f7 /source/blender/freestyle/intern/python/Interface0D/ViewVertex | |
parent | 3c60dd404ef7d715d4633823afb3963b8be1b2ac (diff) |
Improvements on error handling in the Python API.
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface0D/ViewVertex')
-rw-r--r-- | source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp | 7 | ||||
-rw-r--r-- | source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp | 30 |
2 files changed, 13 insertions, 24 deletions
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp index 74c91856bbd..a6f00ba8549 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp @@ -133,6 +133,7 @@ int NonTVertex___init__(BPy_NonTVertex *self, PyObject *args, PyObject *kwds) self->ntv = new NonTVertex( ((BPy_SVertex *) obj)->sv ); } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); return -1; } @@ -174,10 +175,8 @@ PyObject * NonTVertex_svertex( BPy_NonTVertex *self ) { PyObject * NonTVertex_setSVertex( BPy_NonTVertex *self, PyObject *args) { PyObject *py_sv; - if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: NonTVertex_setSVertex" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; self->ntv->setSVertex( ((BPy_SVertex *) py_sv)->sv ); diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp index 83ec27818fa..f16bcbaab87 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp @@ -172,10 +172,8 @@ PyObject * TVertex_backSVertex( BPy_TVertex *self ) { PyObject * TVertex_setFrontSVertex( BPy_TVertex *self, PyObject *args) { PyObject *py_sv; - if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: TVertex_setFrontSVertex" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; self->tv->setFrontSVertex( ((BPy_SVertex *) py_sv)->sv ); @@ -185,10 +183,8 @@ PyObject * TVertex_setFrontSVertex( BPy_TVertex *self, PyObject *args) { PyObject * TVertex_setBackSVertex( BPy_TVertex *self, PyObject *args) { PyObject *py_sv; - if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: TVertex_setBackSVertex" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O", &SVertex_Type, &py_sv) )) + return NULL; self->tv->setBackSVertex( ((BPy_SVertex *) py_sv)->sv ); @@ -198,10 +194,8 @@ PyObject * TVertex_setBackSVertex( BPy_TVertex *self, PyObject *args) { PyObject * TVertex_setId( BPy_TVertex *self, PyObject *args) { PyObject *py_id; - if(!( PyArg_ParseTuple(args, "O", &py_id) && BPy_Id_Check(py_id) )) { - cout << "ERROR: TVertex_setId" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; if( ((BPy_Id *) py_id)->id ) self->tv->setId(*( ((BPy_Id *) py_id)->id )); @@ -212,10 +206,8 @@ PyObject * TVertex_setId( BPy_TVertex *self, PyObject *args) { PyObject * TVertex_getSVertex( BPy_TVertex *self, PyObject *args) { PyObject *py_fe; - if(!( PyArg_ParseTuple(args, "O", &py_fe) && BPy_FEdge_Check(py_fe) )) { - cout << "ERROR: TVertex_getSVertex" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; SVertex *sv = self->tv->getSVertex( ((BPy_FEdge *) py_fe)->fe ); if( sv ){ @@ -228,10 +220,8 @@ PyObject * TVertex_getSVertex( BPy_TVertex *self, PyObject *args) { PyObject * TVertex_mate( BPy_TVertex *self, PyObject *args) { PyObject *py_ve; - if(!( PyArg_ParseTuple(args, "O", &py_ve) && BPy_ViewEdge_Check(py_ve) )) { - cout << "ERROR: TVertex_mate" << endl; - Py_RETURN_NONE; - } + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; ViewEdge *ve = self->tv->mate( ((BPy_ViewEdge *) py_ve)->ve ); if( ve ){ |