From 9afefdc05ae7ec1127b66ca40a0d71f4f4bfd5ca Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 25 Jan 2017 00:21:45 +0800 Subject: [PATCH] Path.Area: fixed error handling in Python constructor --- src/Mod/Path/App/AreaPyImp.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index 4a6cb3fbd..8cbabda4d 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -109,15 +109,17 @@ std::string AreaPy::representation(void) const return str.str(); } -PyObject *AreaPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper +PyObject *AreaPy::PyMake(struct _typeobject *, PyObject *args, PyObject *kwd) // Python wrapper { - return new AreaPy(new Area); + std::unique_ptr ret(new AreaPy(new Area)); + if(!ret->setParams(args,kwd)) + return 0; + return ret.release(); } // constructor method -int AreaPy::PyInit(PyObject* args, PyObject* kwd) +int AreaPy::PyInit(PyObject* , PyObject* ) { - setParams(args,kwd); return 0; } @@ -254,8 +256,7 @@ PyObject* AreaPy::setParams(PyObject *args, PyObject *keywds) if (!PyArg_ParseTupleAndKeywords(args, keywds, "|" PARAM_PY_KWDS(AREA_PARAMS_CONF), kwlist, PARAM_REF(PARAM_FNAME,AREA_PARAMS_CONF))) - Py_Error(Base::BaseExceptionFreeCADError, - "Wrong parameters, call getParamsDesc() to get supported params"); + return 0; #define AREA_GET(_param) \ params.PARAM_FNAME(_param) = \