From b77d8cac4f8e73f5ee816970b899b414f2fd7272 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 11 May 2017 19:47:54 +0200 Subject: [PATCH] minor fixes for pr749 --- src/App/DocumentObjectPyImp.cpp | 2 +- src/App/DocumentPyImp.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 6dda3c9d16..da62d024d2 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -285,10 +285,10 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args) PyObject* unicode = PyUnicode_AsEncodedString(expr, "utf-8", 0); if (unicode) { std::string exprStr = PyString_AsString(unicode); + Py_DECREF(unicode); boost::shared_ptr shared_expr(ExpressionParser::parse(getDocumentObjectPtr(), exprStr.c_str())); getDocumentObjectPtr()->setExpression(p, shared_expr, comment); - Py_DECREF(unicode); } else { // utf-8 encoding failed diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index d69f4e6958..ce7bda4983 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -346,9 +346,12 @@ PyObject* DocumentPy::openTransaction(PyObject *args) cmd = PyString_AsString(value); } #endif - else + else { + PyErr_SetString(PyExc_TypeError, "string or unicode expected"); return NULL; - getDocumentPtr()->openTransaction(cmd.c_str()); + } + + getDocumentPtr()->openTransaction(cmd.c_str()); Py_Return; }